Beginner's Roblox Scripting Tutorial #10 - Events (Beginner to Pro 2019)
Vložit
- čas přidán 27. 08. 2024
- Beginner's Roblox Scripting Tutorial #10 - Events (Beginner to Pro 2019)
Hey guys, in today's video I am going to be teaching you about roblox events. or events in roblox. Basically, events are things that are fired whenever roblox sees them happen. So things like when a part is touched, or anything like that. These events are also called RBXScriptSignals, but no one ever calls them that so you can probably just remember events. Anyways I hope you guys enjoy the video and I'll see you in the next one!
Link to Beginner's Tutorial Series:
• Beginner's Roblox Scri...
-- Follow me on twitter! (my name is tapwater because thats my main channel): / realtapwater
- Join my Discord Server to learn and meet other developers!-
/ discord
--What is this series about and who is it for?
So this series is meant for people who really want to learn exactly how to script, if that is you then I promise by the time you watch this whole series you will know exactly how to script on roblox. Anyways be sure to subscribe to see whenever I release a new tutorial and I will see you guys in the next one. Peace!
Hey guys! Be sure to join the discord server if you have any questions or if you would like to meet me! discord.gg/FKcSyRh
hi can you teach me how to make a build mode system ike bloxburg
Ool man!
Hi I'm in 2020 right now and sadly this is out dated can you make a new Roblox scripting tutorial (Beginner's)
@@rumfel3 Is it really outdated?
game.Workspace.AwesomePart.Touched:Connect(function()
wait(7)
if AwesomePart.Anchored == true then
wait(2)
AwesomePart.Anchored = false
print"Ow you hurt me"
end
end)
WHY IS IT NOT WORKING
"I wasn't even busy I was just being lazy"
Lol this is a relatable thing XD
He was busy being lazy
@@kennytran2860 HA
same
Aye the man was straight so that's good
The fact he was honest about it.. +respect
To everyone watching this, make sure you give yourself mini-projects/assignments to do after learning something new! If you just watch without practice, you won't get better.
👍👍
i still don't know who joe is
@@worsenedcolor what?
I just write it down in notes and expirement with them
@@mech_electro thats a good way to learn
1:28 I swear my boy was gonna put hotdog XD
Same
Lol
@@miker3715Welp just found my old account
took a bit honestly
All other tutorials just dont feel the same and not motivating, but this guy's tutorials, they are just magic, I owe this man my entire developer career and motivation to be a developer.
he teaches really good and makes jokes so its entertaining
@@9kxrelocal hotdog = yourComment
local hotdog = facts
@@giraffelove12
If yourComment == facts then ()
you received a like from me
end
@@squash9189 I feel like I didnt even word it right because
if myComment == true then
print(“its true”)
else
print (“no”)
end
and it printed “no”
@@squash9189 correction:
local function GiveLike()
yourComment.Likes = 1
end
if yourComment.Facts == true then
GiveLike()
end
Thanks man! As soon as this video started and I seen you put touched I instantly said "is this how you can make they team doors on they games?" and instantly tried coding that myself and it worked all because of your help as beginner as that sounds I was so proud xd
same with me but just doors in general
True, is beginners are like, Woah I made this! Pros be like, Oh cool
Whenever I learn from games, I payed for a game that teaches you to script I get headaches. Then I turn on your channel and suddenly it all makes sense...
He's like the Indian guy teaching you math but for scripting! Lol.
there is a new game called "scripting school", and it's free and very helpfull.
yes I replied after four years
This guy has one of the most high understanding of teaching on CZcams. I would recommend to finish his series 100%
him: hey guys it’s the dev king
captions: hi guys it’s the deaf king
because captions are deaf
lol this is the only recent comment ive seen
Notice.
@@WildDreamer19 Notice
@@amiroto8449 Year 3: Notice
Dude your tutorials are actually helping me learn a lot. I learned how to make the platform fall after a couple of seconds because of your videos.
bro its not that hard to make a platform get fall after a couple of seconds, even my lil bro can do it..
But I understand you, DevKing series is really helpful!..
@@fuzailgaming715 21 December 2022 💀💀💀
@@qarful7pardon, i dont understand
@@fuzailgaming715 pants pants got those ants
Thank you so much. At this episode I did a lot of scripting myself so much. I ended up making my own script where whenever you touch a block it turns red but whenever you get off it turns green bc its happy your not stepping or touching it anymore.
wow that's ADORABLE 🥺
awwww
I love your channel I just found it today and I already know soo much more! Thank you 😊
Gaming Guns sameeeeee 😄
Same.
Ikrr
Same
Thanks so much for this, after watching this series so far I think I'll finally be able to code something myself instead copypasting scripts from tutorials to get the stuff i want.
Yup. That is basically what I have been doing until I found out about these videos
This guy's tutorials are so helpful, as soon as he started showing us what to do in the script I paused it and did it all myself without help, thanks to his tutorials.
EXACT SAME THING LOL
lets be honest: when he said that you could go to the next tutorial
*you didn't*
Edit: for those missing context, at the end he said that you can go ahead to skip to the next video but nobody wanted to because we are learning scripting
This is false.
and a lot of other people probably think that it's false aswell
@@eternity-308 nah hes right because im about to go back and watch the first ten so i can correct my mistake of not writing anything down
lol
@@BottledSam oof I edited my comment. Forgot to add context
@@BottledSam how is it so far
Even though I'm watching this 4 years later, it helps so much. Thanks DevKing
Same here! This stuff really helps
same here
me too! just learning today, didn't know that roblox studio was a great game engine
Another fantastic tutorial! I love how I not only learn something but also have a lot of fun learning it! :D
Same!!
im crying in shame while watching this video
I thought I could never learn how to script because of these bad tutorials. I only knew the print script a bit but that was it. Today I learned many things. Thank you so much. If I would ever get famous I would tell my viewers to subscribe to you :)
Bad tutorials from him????
HOW IS THIS SERIES SO USEFULLLL
@@shreyanm.9581 the dev king is good
I didn’t stop hating on the CZcamsr, he is just trying to help ppl and you’re hating
they are both good
@@shreyanm.9581 in my opinion I found that thedevking gave me more information
@@shreyanm.9581 also guess what I'm learning things from thedevking like how everything works and in alvin they just make a kit of piggy games or egg hatching things for simulators.
yo devking thanks a lot for the series i've only gotten here so far and i will keep on going until the last part and just from episode 10, I am able to understand some basics of coding! Thank you so much dude!
Only a bit of people are here compared to the first episode, thanks for getting here!
guys what he's trying to do towards the end does work but he just forgot wait(), anyways here's the script:
local function onTouched()
wait(1)
script.Parent.Anchored = false
wait(1)
script.Parent.Anchored = true
end
script.Parent.Touched:Connect(onTouched)
Your pfp got me
@@joshualee6852 imagine not using dark mode
The Blinking Brownie what in the f*** does that have to do with events?
@@crystalscreens9057 It has nothing to do with events, Joshua said that Person's profile picture got him. Well his profile picture is a fly sitting on a default picture with a white background. To be fooled by that you also need a white background which means Joshua did not use dark mode.
The Blinking Brownie and does it matter of we don't use dark mode? Sometimes people like the light more than the dark.
5:44 Just adding on to the obby idea, If you don't want the part to fall immediately, add a wait(1) or wait(2) to the function.
Also, you can make it turn red before the wait function to signal that its gonna fall. And if you would like, you could part:Destroy() after 10 seconds or so to prevent lag lol.
@@liamm347 how you get it to respawn tho
with this video i made a script that it rickrolls my brother
:tomato:
@@cortiz8726 easy replicate it into replicated storage and set it to spawn 10 seconds after the script destroys the block
so
local replicatedpart = game.replicatedstorage.part:Clone
wait(10)
replicatedpart.parent = game.Workspace
You managed to fit something that usually takes hours to teach into just 10 minutes, if you say you are not one of the best Roblox scripters ever, you're lying.
i love your tutorials i made a simple door open when button touched script from your tutorials (my first script) so if u wanna review it then here it is
make sure you have a part called "Button" near a part called "Door" Resizing is optional
local door = game.Workspace.Door
local function open()
door.Transparency = 0.5
door.CanCollide = false
wait(3)
door.Transparency = 0
door.CanCollide = true
end
game.Workspace.Button.Touched:Connect(open)
good job!
your script helped me make a button that activates a color changing part
Ive watched alvin bloxs series and 10 episodes of yours and i combined alvins tutorial with yours while you were printing using the touched event i was make it change transparency material and color when you touch the part
Using a function to signal an Event in another script is a smart way of coding chain events.
thanks to your tutorials i made a working door using Events, if statements and object-oriented programming, huge thanks to you bud : )
Im already know these functons and just watch this series because Im bored and dont have motivation to do something, but Im really impressed how good you can explain something. Good job, dude👍
Notes:
If you go to view and find the object browser, you can see different events and other things you can use in code. Its better to use the wiki
Parts have children that are events. Events have lightning symbols.
After you type the event you type :connect(function()
This will make a function that is called when the event happens
Example:
Part.Touched:Connect(function()
Print (yes)
end)
And when you touch that part, then yes will be printed
If an event is ran, you can use a wait code, but if it’s ran again, the event wont wait, and it will restart the function from start. Another way to do this is
local function [insert the name of your function]()
[code]
end
part.Touched:Connect([insert name of your function])
Thanks for making these videos, it is really helping me understand what does what, and how certain things work, you explain it in such a way that I can understand, when no one else has been able to.
I know this is really late but these tutorials really helped me! I am finally starting to learn to script and I’m having fun doing it can’t wait to get to the advanced tutorials
The real fun is starting in the advanced tutorials, animations, tools and many more. Keep going trought that 💪
@@b4rtolinek51 🌝 🕺 💨👧 🌚
i got mad because my script wasnt working until i noticed the function was not written wrtie lol this so helpful
Yeah you didnt spell it wrtie because of that
This is the 3rd day watching your tutorials. Thanks man! All the tutorials was too short yet i can understand it easily!!
i love how he makes it fun by adding in Hotdog as a variable every time :))
Tip to learning faster and understand: try to get any idea you want to make for a game, try make it super simple then search in youtube how to script it and then do it with another ideas then come back and watch TheDevKing Tutorials and if you didn't understand then watch the video again and try turn on CC so you wont miss a word
still watching this guy after years W developer imo
"hope you know what i mean"
me : yes i hope too lol
This guy doesn’t waste anytime, most youtubers just blah blah blah for like 75% of the video then don’t even explain what they are trying to explain good. He blah blah blah for like 5% of the video then he explains what he needs to explain really well.
its so perfect its like your friend explaining something to you
one thing you can do is run the script local Part=game.Workspace.Part so you can do Part.Touched:Connect()
Are you going to be teaching more events?
No
@@joshuajurado939 thanks you were just a year and a half late
@@Luke-db1ev 👨🏿👨🏿👱🏻♀️👨🏿👨🏿👨🏿🦳
If you are gonna make a bunch of falling parts that have the same name use this because if you don't, only one of the parts are gonna fall, also instead of putting this into the workspace, put it into the part.
local function EpicFall()
script.Parent.Anchored = false
end
script.Parent.Touched:Connect(EpicFall)
so basically after watching this video and all other videos before it i decided to test what i can do and i did it 2 different ways one i set up 8 bricks where when you touch them they turn red and if all 8 brick are red then a coin appears in the middle and the second way im about to try is using the touch ended event when when the touch is ended the the coin is invisible but when touched it isn't and there is only one brick this time but you have to push something ontop of the brick and then get the coin
nice scripting
you kinda gave me a idea to make a script where like if u collect the coin it goes transparent so heres what i came up with im pretty proud of it:
local Coin = game.Workspace.Coin
local function CoinAppear()
Coin.Transparency = 0.2
end
local function CoinDisappear()
Coin.Transparency = 1
end
game.Workspace.Coin.Touched:Connect(CoinAppear)
game.Workspace.Coin.TouchEnded:Connect(CoinDisappear)
-- end
also im new to scripting so sorry if it isnt completely functional lol
This is when the fun really starts because once you know how to teleport it then you can make like "Cant reach me!"
I just experimented with these commands; events are so cool!
A great roblox dev teacher always sets hotdog as an example.
this will make doing a lot of things a lot easier
GamingMaster YT yeshir
LOL. Love his attitude "wasnt even busy or something, just been lazy"
I’ve watched many many scripting tutorials of anything but mostly explaining events. Your video was the most useful and had the best and most straight-forward explanation, thank you!
Even tho I'm watching this 4 years later it is still a very useful video
I like that the tutorials give clear instructions. The videos help me a lot, thanks!
Thank you for these, I really feeling like I'm getting somewhere quickly
5:03 that sudden focus is so funny lol
finally I could understand events for the first time :)
If you have problems with the Part printing when touching the baseplate, you can also make it only run if the player touches it. (USES PARAMETERS)
game.Workspace.Banana.Touched:Connect(function(Hit)
if game.Players:GetPlayerFromCharacter(Hit) then
print("Ahh!")
print(Hit)
end
end)
In line 1 When something touches the part, the touched event returns data to the parameter (Hit) the parameter will now equal to the data it sent eg. Left leg (Think of the parameter like a variable)
In line 2 The script checks to see if the body part that touched the part is a player (It checks for a player in the character, an NPC can be a character but it can't be a player) if it is a player it will run line 3
In line 3 it prints "don't touch me"
end
But to be honest Im not sure myself how line 2 works :')
Nice refresher for someone like me who forgets quite a bit
Ok so at the end he means you have to put the wait on the top for example:
wait()
game.Workspace.Part.Anchored = false
And it’s like waiting to reach the end of the line guys
I hope this will help you understand anyway
I'm sure he goes over this later but if anyone is interested this is how you stop the touched event from firing a bunch of times:
local MyPart = game.Workspace.Partname
local debounce = true
MyPart.Touched:Connect(function()
if debounce == true then
debounce = false
print("hi")
wait(10)
debounce = true
end
end)
if you want to decrease the ammount of times it touches i found that putting
game.Workspace["part"].CanTouch = false
wait(ammount of time)
game.Workspace["part"].CanTouch = true
it doesnt really work very consistently but instead of giving you 100 reactions in a second it gives 4 at maximum
I suggest to take notes...really saves you time rewatching tutorials
this video helped and also this video came out on my birthday
Scripting is really fun! I get so excited whenever I learn a new thing about scripting.
I’m back here again because I haven’t coded in so long lol
YO DUDE THANK YOU SO MUCH
I made it so if you don’t go up the staircase in time the part that your standing on will have CanCollide turned out off, so if you stand on a part too long (1 second) you will fall through but when you do the script will turn CanCollide on in 3 seconds so you can do it again without having it to be permanently disabled.
Thank you so much, although it’s not much you have helped me accomplish something I have never done before as a beginner in scripting.
+1 sub
Thank you
9:43 "you can go to next toturial if you want"
*literally tells something important at the end*
never forget to turn on anchor
To explain it better an event is called when something happens some are built in game some have to be made, like in real life u fall then u get hurt, in game u fall then u get damage i think is clear.
Hey, if youre doing this tutorial and realize your code is not working, making sure to put a ) next to end!
like this: end)
and this should fix your event not activating.
3:27 if from this script your function doesnt work just delete spaces that putted automaticly
Please keep this up these videos are so helpful
Bro you explain so well because of you I can code and script now thanks so much dude!
"I have multiple body parts"
I do too!
still W vid, as always
3 years ago this was the video that was the turning point for my scripting journey... but back then it caused me to not watch the rest of the videos which leads to today although im good at scripting despite it
I know this might be an old vid but you inspired me to start my own ROBLOX channel!
remember watching this 2 years ago hyped as hell lol, know i pretty much know how to script. never made a big game tho. havent really tried neither tho lol
u should
I like how the auto-captions hear his name as "The deaf king."
about an hour in watching these and i have learned so much like even before he made the part fall what i did with the info is i made a part named pheac and a sign that says "dont touch pheec he get mad and kill" and made the baseplate fall whenever pheec was touched and i saw him do it after me and i was like BRO NAHH HE READ MY MIND
I would recommend the first way, it's more complete and concise. It'll make your code look cleaner when you're scripting, which can relive alot of eye strain from so much text.
Personally, I’d like to see so much text because it tells me how much I’ve learned. It motivates me to learn more for some reason. But I do think too that the first method make your script more cleaner.
500th comment pog im enjoying these guides so far even after all this time
i noticed that many people started saying that u guys dont the code like to print 1000 times per seconds, to fix this, you can type wait(the time u want it to wait for in seconds) and put another print in the next line, now it will wait 1 seconds before printing again, thank me later
the thing that is good about this is that if you want to make like a squid game glass bridge this can be usefull so the glass does not just stay in the air!
Me as a noob oh so now we getting interesting ight I see how it is XD
Am barley getting started with scripting
Same!
But i also good modeler
Without that playlist I would never make a roblox game.
For the last part, i think the wait time of 1 second was short and by the time a second passed, the part already touched the ground. i kept a wait time of 0.5 seconds and it worked for me.
game.Workspace.Part.Anchored = true
local function anchorremoval()
game.Workspace.Part.Anchored = false
wait(0.5)
game.Workspace.Part.Anchored = true
end
local function start()
game.Workspace.Part.Touched:Connect(function()
anchorremoval()
end)
end
start()
what i did was put it to where when you touch the part, it unanchores it then prints, i was touched so i fall. so i just clicked play, stepped on it, then it tells me, i was touched so i fall. Idk why but it just made me giggle to myself outloud.
bruh UR THE BEST HELPFULL yt in the planet! UGHhhh i wanna sub 900x times rn
rlly good tuts i literally made a obby and made that one glass game from squid game where u have to guess which one is safe
Absolutely amazing tutorial!
in the second method of the touch event, how does one add parameters if they dont allow parenthesis
Tysm! I’m learning to code and this was really usefull!
5:56 this is the script that is used to make the glass break squid gqme in roblox without prints
true
This is the most fun one yet
I Made Small Edits To That, here it Is
local function HumanoidPart()
print("Function Called")
print("Yo How Heavy Are You?")
game.Workspace.Part.Anchored = false
game.Workspace.Baseplate.Anchored = false
end
game.Workspace.Part.Touched:Connect(HumanoidPart)
for your testing at the end you had to do it with while true do :)
I got an idea, whenever a part is step on, it will get mad and there will be like a gui on top of your screen saying DON'T STEP ON ME and it will be raining parts
Thanks ! I been trying to learn the most helpful thing ever!
this was the most useful roblox studio scripting tutorial video i ever seen
This series is so helpful 😭
Thanks to you I figured out how to script my game so then when you walk over The part it turns neon and Prints shine bright
game.Workspace.Part.Touched:Connect(function()
print("You are not the father")
end)
thank you dev king you did a really great job explaining but I have a question: so when we are doing and event for something we can connect like a raw function into it?