Edit (I wanna put this at the top because its more important lol): 4:53. The variable "TouchedEvent" is nil if you declare on the same line as you make the connection. This is due to how lua handles variable scoping and closures (A closure is a variable inside a function created outside the function). If you declare the variable before the connection is made, then that variable will be in the function's scope meaning the function will have access to it, HOWEVER, if you declare the variable on the same line that the function is created it means that the function is created before the closure is declared. This means the closure is not inside of the function's scope meaning the function has no access to it which is why you get the orange underline. Pretty much its just roblox being a goofball lol! (End of Edit) Great vid but to go into more specific things about events for anyone curious and trying to go that extra level up: At 3:23, The event isn't connected to the function. The function is what we call a "Callback function" (which is just a function that is ran whenever a condition is met). What Connect is a method within the class, RBXscriptsignal (in this case .Touched). Methods are essentially functions that are owned by a class and the class in this case is the "RBXScriptsignal" class. Since Connect is a function, it mean it takes parameters. Connect takes a function as a parameter. This function will run whenever the event occurs (for example, .Touch will run the function when the part is touched). Then, :Connect() will returns an RBXScriptConnection (which is what this video is about). RBXScriptConnection is a class which contains 1 method which is Disconnect(). Disconnect will make it so the connection will stop trying to run the function.
@@byteblox100 very interesting. Just wanna say that you're my favourite tutorial channel. Legit one of the only channels out there actually teaching people stuff rather than just giving scripts lmao (Im guilty of this...)
@@slaveisa06 not rlly... I made that months ago when I was still quite new to scripting. If you're a hacker, you could literally just fire the hitbox event to the server with whatever size and damage you want meaning you could just instantly kill the entire server forever. Also it uses .Touched which is terrible for hitboxes!!!
In other words: Imagine Disconnect() being the opposite of Connect(). Connect() connects a function to whatever a object or variable does. Disconnect() disconnects that function from the object.
Your videos are easy to understand and concise, so everyone who is experienced or even new can understand the concept and use their own version of it. It’s short and easy. Great videos
Thanks so much for making this video. It was really informative and helpful. Suggestion: Raycasting (specifically mouse raycasting where you can detect which part in the workspace the mouse clicks)
You don’t actually need raycasting for that. You could just use userinputservice fire a function when a player clicks the mouse, and Mouse.Hit to find the part the mouse is hovering over when it was clicked. (You could use raycasting depending on what you are doing)
@@ScriptedExpert I’m almost positive that the only way to get the object a mouse clicks is by using raycasting. Mouse.hit merely provides the coordinates within the 3d plane that the mouse hit, it does not return the object the mouse clicks on.
You can't call the connection when you instantly set it because it's SETTING itself to that variable, you can't equal something to itself if that something doesn't exist yet, that's why you first make a fake variable with a nil value, and then set the value to the connection
5:42 In other words: When you disconnect that function, you would be destroying the function that is currently running the code and that would fuck with the computer's head. But if you do it to a variable that initially was something else, the computer understands.
You can use a variable inside of the connection's function, it's just that the script editor doesn't notice that it's already been declared prior to the function is being introduced.
global variables are the opposite of local variables the diffrence between them is their scope, imagine a function local function sample() local variable="Hello, World" end sample() print(variable) -- here you'll get an error because the scope of a local variable is limited, if you declared it inside a function you cant use it outside the function But if you use _G.variable its now global
I am currently crying so hard right now. This is seriously the most beautiful, well put together story ever. I can’t believe how magical it was 1:12. That part truly made me shed a tear. And especially at 6:34 that part was just so truly heart touching words can not describe the series of emotions I felt. I absolutely loved the climax it had insanely excellent detail. Oh and we can’t forget the conclusion. The conclusion was the greatest and saddest conclusion I have ever seen better than any of the books I have read. Thank you so much for creating this absolute masterpiece. This is essentially the most important masterpiece of film history. It is a tragedy that this, it can’t be called a film, but a transcendent emotional experience, will be inaccessible for most. It beautifully encapsulates the human struggle to its basics; suffering, pleasure, faith, despair. It connects with the characters within the viewers, individuals suppressed within our own subconscious. It stays vibrant, fresh, and revolutionizes the art of storytelling and filmmaking while making a damn of statement on what it means to be human. Entertaining, gripping, and simply exhilarating. This might be the most impactful piece of art I’ve come across in my life, and I’m definitely coming back to it in the near future to study it more deeply. this is an absolute masterpiece , I was brought to tears listening to this and seeing the bacon go whirly swirly in a circle countless times. it absolutely moved my soul , and I don't think I can ever be the same. this bacon has changed my entire mental state , I am now at peace with who I am and what I will be doing later in my life. i have forgiven all my enemies and now I am a man of a pacifist life. I will move on , gotta move on , as the song says. the bacon is so inspirational , it shares it vast wisdom with all of us , and we are all so lucky that it would bestow it's great words with us. we are all children on bacon. hail bacon. hail bacon. The spinning bacon, rotating in one direction with this music... This made me tear up. How could such a bacon do such a thing? I'm struck by awe by this masterpiece. Especially when the bacon spins, showing its lightly salt covered tan skin. I can hear the crunch just from here, and so as the beautiful sound of the bacon scraping the dark, smooth velvet floor. The flavor, music and everything can be heard, tasted, seen and felt from a screen. You can really hear the breaths between the music artist, empathizing her love for this rotating bacon. Truly what I call modern art. This was the most legendary performance by any piece of bacon I have ever watched. The acting was top tier and very life changing. This is one of the greatest work from a piece of bacon I have ever seen especially on 57:42.I am currently crying so hard right now. This is seriously the most beautiful, well put together story ever. I can’t believe how magical it was at 1:12. That part truly made me shed a tear. And especially at 6:34 that part was just so truly heart touching words can not describe the series of emotions I felt. I absolutely loved the climax it had insanely excellent detail. Oh and we can’t forget the conclusion. The conclusion was the greatest and saddest conclusion I have ever seen better than any of the books I have read. Thank you so much for creating this absolute masterpiece. This is essentially the most important masterpiece of film history. It is a tragedy that this, it can’t be called a film, but a transcendent emotional experience, will be inaccessible for most. It beautifully encapsulates the human struggle to its basics; suffering, pleasure, faith, despair. It connects with the characters within the viewers, individuals suppressed within our own subconscious. It stays vibrant, fresh, and revolutionizes the art of storytelling and filmmaking while making a damn of statement on what it means to be human. Entertaining, gripping, and simply exhilarating. This might be the most impactful piece of art I’ve come across in my life, and I’m definitely coming back to it in the near future to study it more deeply. this is an absolute masterpiece , I was brought to tears listening to this and seeing the bacon go whirly swirly in a circle countless times. Tt absolutely moved my soul , and i don't think I can ever be the same. this bacon has changed my entire mental state , I am now at peace with who I am and what I will be doing later in my life. i have forgiven all my enemies and now I am a man of a pacifist life. I will move on , gotta move on , as the song says. the bacon is so inspirational , it shares it vast wisdom with all of us , and we are all so lucky that it would bestow it's great words with us. we are all children on bacon. hail bacon. hail bacon. The spinning bacon, rotating in one direction with this music... This made me tear up. How could such a piece of bacon do such a thing? I'm struck by awe by this masterpiece. Especially when the bacon spins, showing its lightly salt covered tan skin. I can hear the crunch just from here, and so as the beautiful sound of the bacon scraping the dark, smooth velvet floor. The flavor, music and everything can be heard, tasted, seen and felt from a screen. You can really hear the breaths between the music artist, empathizing her love for this rotating bacon. Truly what I call modern art. This was the most legendary performance by any bacon I have ever watched. The acting was top tier and very life changing. This is one of the greatest work from a bacon I have ever seen especially on 17:24. I am currently crying so hard right now. This is seriously the most beautiful, well put together story ever. I can’t believe how magical it was 1:12. That part truly made me shed a tear. And especially at 6:34 that part was just so truly heart touching words can not describe the series of emotions I felt. I absolutely loved the climax it had insanely excellent detail. Oh and we can’t forget the conclusion. The conclusion was the greatest and saddest conclusion I have ever seen better than any of the books I have read. Thank you so much for creating this absolute masterpiece. This is essentially the most important masterpiece of film history. It is a tragedy that this, it can’t be called a film, but a transcendent emotional experience, will be inaccessible for most. It beautifully encapsulates the human struggle to its basics; suffering, pleasure, faith, despair. The work put in to this is incredibly inspiring. The graphics, the animation, the music, so much thought was put into it. This has remined me that you can do anything you put your mind to. Not even mentioning the memories, this makes me feel like an infant again, just laying my eyes on this beautiful masterpiece gives me all the good feelings in life. I also understand what happiness is again from this. Not even to mention the most incredible part that is 2:10. Bacon spinning has changed my life for the better. It connects with the characters within the viewers, individuals suppressed within our own subconscious. It stays vibrant, fresh, and revolutionizes the art of storytelling and filmmaking while making a damn of statement on what it means to be human. Entertaining, gripping, and simply exhilarating. This might be the most impactful piece of art I’ve come across in my life, and I’m definitely coming back to it in the near future to study it more deeply. this is an absolute masterpiece , I was brought to tears listening to this and seeing the bacon go whirly swirly in a circle countless times. it absolutely moved my soul , and I don't think I can ever be the same. this bacon has changed my entire mental state , I am now at peace with who I am and what I will be doing later in my life. So much great graphic design, so much suspense, so much greatness in this one video. i have forgiven all my enemies and now I am a man of a pacifist life. I will move on , gotta move on , as the song says. the bacon is so inspirational , it shares it vast wisdom with all of us , and we are all so lucky that it would bestow it's great words with us. we are all children on bacon. hail bacon. hail bacon. The spinning bacon, rotating in one direction with this music... This made me tear up. How could such a bacon do such a thing? I'm struck by awe by this masterpiece. Especially when the bacon spins, showing its lightly salt covered tan skin. I can hear the crunch just from here, and so as the beautiful sound of the bacon scraping the dark, smooth velvet floor. The flavor, music and everything can be heard, tasted, seen and felt from a screen. You can really hear the breaths between the music artist, empathizing her love for this rotating bacon. Truly what I call modern art. This was the most legendary performance by any bacon I have ever watched. The acting was top tier and very life changing. This is one of the greatest work from a piece of bacon I have ever seen especially on 57:42. I am crying. This has made me go through an emotional rollercoaster. I cried, beat off, and also watched a movie while watching this premiere. This has made me go through so much. I passed depression because of this. It really inspired me to become an outstanding young
Get all of my knowledge in one package: linktr.ee/ByteBlox
Edit (I wanna put this at the top because its more important lol): 4:53. The variable "TouchedEvent" is nil if you declare on the same line as you make the connection. This is due to how lua handles variable scoping and closures (A closure is a variable inside a function created outside the function). If you declare the variable before the connection is made, then that variable will be in the function's scope meaning the function will have access to it, HOWEVER, if you declare the variable on the same line that the function is created it means that the function is created before the closure is declared. This means the closure is not inside of the function's scope meaning the function has no access to it which is why you get the orange underline. Pretty much its just roblox being a goofball lol! (End of Edit)
Great vid but to go into more specific things about events for anyone curious and trying to go that extra level up: At 3:23, The event isn't connected to the function. The function is what we call a "Callback function" (which is just a function that is ran whenever a condition is met). What Connect is a method within the class, RBXscriptsignal (in this case .Touched). Methods are essentially functions that are owned by a class and the class in this case is the "RBXScriptsignal" class. Since Connect is a function, it mean it takes parameters. Connect takes a function as a parameter. This function will run whenever the event occurs (for example, .Touch will run the function when the part is touched).
Then, :Connect() will returns an RBXScriptConnection (which is what this video is about).
RBXScriptConnection is a class which contains 1 method which is Disconnect(). Disconnect will make it so the connection will stop trying to run the function.
That’s really interesting
@@byteblox100 very interesting. Just wanna say that you're my favourite tutorial channel. Legit one of the only channels out there actually teaching people stuff rather than just giving scripts lmao (Im guilty of this...)
@@MajesticUC your punching tutorial is very good
@@slaveisa06 not rlly... I made that months ago when I was still quite new to scripting. If you're a hacker, you could literally just fire the hitbox event to the server with whatever size and damage you want meaning you could just instantly kill the entire server forever. Also it uses .Touched which is terrible for hitboxes!!!
There's also :Once() which is like :Connect() but it disconnects itself after it being fired once.
Ohhh very useful!
In other words:
Imagine Disconnect() being the opposite of Connect(). Connect() connects a function to whatever a object or variable does. Disconnect() disconnects that function from the object.
not object but signal
Thanks@@rashy15
I have been scripting on roblox for a few years but today i actually learned something new, +1 sub to you!
Your videos are easy to understand and concise, so everyone who is experienced or even new can understand the concept and use their own version of it. It’s short and easy. Great videos
I feel like if im going to watch these videos daily, i can learn Lua scripting, im enjoying your content!
Thanks so much for making this video. It was really informative and helpful.
Suggestion: Raycasting (specifically mouse raycasting where you can detect which part in the workspace the mouse clicks)
You don’t actually need raycasting for that. You could just use userinputservice fire a function when a player clicks the mouse, and Mouse.Hit to find the part the mouse is hovering over when it was clicked. (You could use raycasting depending on what you are doing)
@@ScriptedExpert I’m almost positive that the only way to get the object a mouse clicks is by using raycasting. Mouse.hit merely provides the coordinates within the 3d plane that the mouse hit, it does not return the object the mouse clicks on.
bro you are the best roblox studio youtuber
I remember learning this a few years ago and it was very cool.
You can't call the connection when you instantly set it because it's SETTING itself to that variable, you can't equal something to itself if that something doesn't exist yet, that's why you first make a fake variable with a nil value, and then set the value to the connection
That makes snese
I never knew this was a thing this is going to help a lot
You are too underrated same with your newsletter I read it everyday
5:42
In other words:
When you disconnect that function, you would be destroying the function that is currently running the code and that would fuck with the computer's head. But if you do it to a variable that initially was something else, the computer understands.
You can use a variable inside of the connection's function, it's just that the script editor doesn't notice that it's already been declared prior to the function is being introduced.
global variables are the opposite of local variables the diffrence between them is their scope, imagine a function
local function sample()
local variable="Hello, World"
end
sample()
print(variable) -- here you'll get an error because the scope of a local variable is limited, if you declared it inside a function you cant use it outside the function
But if you use _G.variable its now global
yo, you taught me a bunch of stuff. thank you, you're the best.
i wish i was good at making vids as you
bro is so underrated
this is nice, you can make cleanup functions
totally! The Janitor and Maid modules both use disconnect()
I am currently crying so hard right now. This is seriously the most beautiful, well put together story ever. I can’t believe how magical it was 1:12. That part truly made me shed a tear. And especially at 6:34 that part was just so truly heart touching words can not describe the series of emotions I felt. I absolutely loved the climax it had insanely excellent detail. Oh and we can’t forget the conclusion. The conclusion was the greatest and saddest conclusion I have ever seen better than any of the books I have read. Thank you so much for creating this absolute masterpiece. This is essentially the most important masterpiece of film history. It is a tragedy that this, it can’t be called a film, but a transcendent emotional experience, will be inaccessible for most. It beautifully encapsulates the human struggle to its basics; suffering, pleasure, faith, despair. It connects with the characters within the viewers, individuals suppressed within our own subconscious. It stays vibrant, fresh, and revolutionizes the art of storytelling and filmmaking while making a damn of statement on what it means to be human. Entertaining, gripping, and simply exhilarating. This might be the most impactful piece of art I’ve come across in my life, and I’m definitely coming back to it in the near future to study it more deeply. this is an absolute masterpiece , I was brought to tears listening to this and seeing the bacon go whirly swirly in a circle countless times. it absolutely moved my soul , and I don't think I can ever be the same. this bacon has changed my entire mental state , I am now at peace with who I am and what I will be doing later in my life. i have forgiven all my enemies and now I am a man of a pacifist life. I will move on , gotta move on , as the song says. the bacon is so inspirational , it shares it vast wisdom with all of us , and we are all so lucky that it would bestow it's great words with us. we are all children on bacon. hail bacon. hail bacon. The spinning bacon, rotating in one direction with this music... This made me tear up. How could such a bacon do such a thing? I'm struck by awe by this masterpiece. Especially when the bacon spins, showing its lightly salt covered tan skin. I can hear the crunch just from here, and so as the beautiful sound of the bacon scraping the dark, smooth velvet floor. The flavor, music and everything can be heard, tasted, seen and felt from a screen. You can really hear the breaths between the music artist, empathizing her love for this rotating bacon. Truly what I call modern art. This was the most legendary performance by any piece of bacon I have ever watched. The acting was top tier and very life changing. This is one of the greatest work from a piece of bacon I have ever seen especially on 57:42.I am currently crying so hard right now. This is seriously the most beautiful, well put together story ever. I can’t believe how magical it was at 1:12. That part truly made me shed a tear. And especially at 6:34 that part was just so truly heart touching words can not describe the series of emotions I felt. I absolutely loved the climax it had insanely excellent detail. Oh and we can’t forget the conclusion. The conclusion was the greatest and saddest conclusion I have ever seen better than any of the books I have read. Thank you so much for creating this absolute masterpiece. This is essentially the most important masterpiece of film history. It is a tragedy that this, it can’t be called a film, but a transcendent emotional experience, will be inaccessible for most. It beautifully encapsulates the human struggle to its basics; suffering, pleasure, faith, despair. It connects with the characters within the viewers, individuals suppressed within our own subconscious. It stays vibrant, fresh, and revolutionizes the art of storytelling and filmmaking while making a damn of statement on what it means to be human. Entertaining, gripping, and simply exhilarating. This might be the most impactful piece of art I’ve come across in my life, and I’m definitely coming back to it in the near future to study it more deeply. this is an absolute masterpiece , I was brought to tears listening to this and seeing the bacon go whirly swirly in a circle countless times. Tt absolutely moved my soul , and i don't think I can ever be the same. this bacon has changed my entire mental state , I am now at peace with who I am and what I will be doing later in my life. i have forgiven all my enemies and now I am a man of a pacifist life. I will move on , gotta move on , as the song says. the bacon is so inspirational , it shares it vast wisdom with all of us , and we are all so lucky that it would bestow it's great words with us. we are all children on bacon. hail bacon. hail bacon. The spinning bacon, rotating in one direction with this music... This made me tear up. How could such a piece of bacon do such a thing? I'm struck by awe by this masterpiece. Especially when the bacon spins, showing its lightly salt covered tan skin. I can hear the crunch just from here, and so as the beautiful sound of the bacon scraping the dark, smooth velvet floor. The flavor, music and everything can be heard, tasted, seen and felt from a screen. You can really hear the breaths between the music artist, empathizing her love for this rotating bacon. Truly what I call modern art. This was the most legendary performance by any bacon I have ever watched. The acting was top tier and very life changing. This is one of the greatest work from a bacon I have ever seen especially on 17:24. I am currently crying so hard right now. This is seriously the most beautiful, well put together story ever. I can’t believe how magical it was 1:12. That part truly made me shed a tear. And especially at 6:34 that part was just so truly heart touching words can not describe the series of emotions I felt. I absolutely loved the climax it had insanely excellent detail. Oh and we can’t forget the conclusion. The conclusion was the greatest and saddest conclusion I have ever seen better than any of the books I have read. Thank you so much for creating this absolute masterpiece. This is essentially the most important masterpiece of film history. It is a tragedy that this, it can’t be called a film, but a transcendent emotional experience, will be inaccessible for most. It beautifully encapsulates the human struggle to its basics; suffering, pleasure, faith, despair. The work put in to this is incredibly inspiring. The graphics, the animation, the music, so much thought was put into it. This has remined me that you can do anything you put your mind to. Not even mentioning the memories, this makes me feel like an infant again, just laying my eyes on this beautiful masterpiece gives me all the good feelings in life. I also understand what happiness is again from this. Not even to mention the most incredible part that is 2:10. Bacon spinning has changed my life for the better. It connects with the characters within the viewers, individuals suppressed within our own subconscious. It stays vibrant, fresh, and revolutionizes the art of storytelling and filmmaking while making a damn of statement on what it means to be human. Entertaining, gripping, and simply exhilarating. This might be the most impactful piece of art I’ve come across in my life, and I’m definitely coming back to it in the near future to study it more deeply. this is an absolute masterpiece , I was brought to tears listening to this and seeing the bacon go whirly swirly in a circle countless times. it absolutely moved my soul , and I don't think I can ever be the same. this bacon has changed my entire mental state , I am now at peace with who I am and what I will be doing later in my life. So much great graphic design, so much suspense, so much greatness in this one video. i have forgiven all my enemies and now I am a man of a pacifist life. I will move on , gotta move on , as the song says. the bacon is so inspirational , it shares it vast wisdom with all of us , and we are all so lucky that it would bestow it's great words with us. we are all children on bacon. hail bacon. hail bacon. The spinning bacon, rotating in one direction with this music... This made me tear up. How could such a bacon do such a thing? I'm struck by awe by this masterpiece. Especially when the bacon spins, showing its lightly salt covered tan skin. I can hear the crunch just from here, and so as the beautiful sound of the bacon scraping the dark, smooth velvet floor. The flavor, music and everything can be heard, tasted, seen and felt from a screen. You can really hear the breaths between the music artist, empathizing her love for this rotating bacon. Truly what I call modern art. This was the most legendary performance by any bacon I have ever watched. The acting was top tier and very life changing. This is one of the greatest work from a piece of bacon I have ever seen especially on 57:42. I am crying. This has made me go through an emotional rollercoaster. I cried, beat off, and also watched a movie while watching this premiere. This has made me go through so much. I passed depression because of this. It really inspired me to become an outstanding young
4:34 you can do this with "while" code
That is not the point.
biteblock
Why is it that people who make actual good videos have such a low amount of subscribers?
why are lamp yiu
Good question
@@byteblox100 you highlight new ideas in development, thats why u call yourself like that.
thats interesting
The avatar 🗿
can u do that wiht remote events
Yes, any event I believe
prut)"hllo world")
Hi hello
how do i connect function back?
Create a new one
Cheese. 🧀
is there a way to like reconnect it?
make another connection but i dont see why you would want to do that
How to make a car
yay
3
dsa
uty
ge