What Does "Disconnect" Really Do?

Поделиться
HTML-код
  • Опубликовано: 3 ноя 2024

Комментарии • 60

  • @byteblox100
    @byteblox100  10 месяцев назад +8

    Get all of my knowledge in one package:
linktr.ee/ByteBlox

  • @MajesticUC
    @MajesticUC 10 месяцев назад +15

    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
      @byteblox100  10 месяцев назад +3

      That’s really interesting

    • @MajesticUC
      @MajesticUC 10 месяцев назад +2

      @@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
      @slaveisa06 10 месяцев назад

      @@MajesticUC your punching tutorial is very good

    • @MajesticUC
      @MajesticUC 10 месяцев назад

      @@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!!!

  • @Judeity
    @Judeity 10 месяцев назад +3

    There's also :Once() which is like :Connect() but it disconnects itself after it being fired once.

    • @QUBIQUBED
      @QUBIQUBED 10 месяцев назад

      Ohhh very useful!

  • @RiftIsTaken
    @RiftIsTaken 10 месяцев назад +14

    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.

    • @rashy15
      @rashy15 10 месяцев назад

      not object but signal

    • @RiftIsTaken
      @RiftIsTaken 10 месяцев назад

      Thanks@@rashy15

  • @CheeseY420
    @CheeseY420 10 месяцев назад +2

    I have been scripting on roblox for a few years but today i actually learned something new, +1 sub to you!

  • @LooperEpic
    @LooperEpic 10 месяцев назад +4

    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

  • @helperhelp2
    @helperhelp2 10 месяцев назад +1

    I feel like if im going to watch these videos daily, i can learn Lua scripting, im enjoying your content!

  • @thatcardiologist3874
    @thatcardiologist3874 10 месяцев назад +2

    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)

    • @ScriptedExpert
      @ScriptedExpert 10 месяцев назад +1

      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)

    • @thatcardiologist3874
      @thatcardiologist3874 10 месяцев назад

      @@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.

  • @austinbutcooler
    @austinbutcooler 10 месяцев назад +2

    bro you are the best roblox studio youtuber

  • @Dann.y
    @Dann.y 10 месяцев назад +1

    I remember learning this a few years ago and it was very cool.

  • @Juanitrox
    @Juanitrox 10 месяцев назад +4

    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

  • @Epicicness
    @Epicicness 10 месяцев назад

    I never knew this was a thing this is going to help a lot

  • @x_gwb
    @x_gwb 10 месяцев назад

    You are too underrated same with your newsletter I read it everyday

  • @KiloDev
    @KiloDev 10 месяцев назад

    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.

  • @GSFigure
    @GSFigure 10 месяцев назад +1

    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.

  • @erickoavenada969
    @erickoavenada969 10 месяцев назад

    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

  • @danzstuff
    @danzstuff 10 месяцев назад

    yo, you taught me a bunch of stuff. thank you, you're the best.

  • @redwoodsteve
    @redwoodsteve 10 месяцев назад

    i wish i was good at making vids as you
    bro is so underrated

  • @execute214
    @execute214 10 месяцев назад

    this is nice, you can make cleanup functions

    • @MajesticUC
      @MajesticUC 10 месяцев назад

      totally! The Janitor and Maid modules both use disconnect()

  • @Lisa-oe1kp
    @Lisa-oe1kp 10 месяцев назад +1

    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

  • @monkineedshisbana
    @monkineedshisbana 10 месяцев назад

    4:34 you can do this with "while" code

    • @SheekyDev
      @SheekyDev 9 месяцев назад

      That is not the point.

  • @star80doessdastuff
    @star80doessdastuff 10 месяцев назад +2

    biteblock

  • @HermesKitindi
    @HermesKitindi 10 месяцев назад

    Why is it that people who make actual good videos have such a low amount of subscribers?

  • @TheLazyEdition
    @TheLazyEdition 10 месяцев назад +3

    why are lamp yiu

    • @byteblox100
      @byteblox100  10 месяцев назад

      Good question

    • @orangdot
      @orangdot 10 месяцев назад

      ​@@byteblox100 you highlight new ideas in development, thats why u call yourself like that.

  • @Rainmar
    @Rainmar 10 месяцев назад

    thats interesting

  • @MrFoxANDnoobie
    @MrFoxANDnoobie 10 месяцев назад

    The avatar 🗿

  • @gdyx
    @gdyx 10 месяцев назад

    can u do that wiht remote events

    • @byteblox100
      @byteblox100  10 месяцев назад

      Yes, any event I believe

  • @xavvvvxd
    @xavvvvxd 10 месяцев назад

    prut)"hllo world")

  • @weo2882
    @weo2882 10 месяцев назад +1

    Hi hello

  • @scriptshowcase5111
    @scriptshowcase5111 8 месяцев назад

    how do i connect function back?

  • @HornetPoster
    @HornetPoster 10 месяцев назад +1

    Cheese. 🧀

  • @crazybolot
    @crazybolot 10 месяцев назад

    is there a way to like reconnect it?

    • @MajesticUC
      @MajesticUC 10 месяцев назад

      make another connection but i dont see why you would want to do that

  • @Fallen_Prince69410
    @Fallen_Prince69410 10 месяцев назад

    How to make a car

  • @ChimkenCucumber
    @ChimkenCucumber 10 месяцев назад

    yay

  • @sadge6430
    @sadge6430 10 месяцев назад

    3

  • @sadge6430
    @sadge6430 10 месяцев назад

    dsa

  • @sadge6430
    @sadge6430 10 месяцев назад

    uty

  • @thecoweggs
    @thecoweggs 10 месяцев назад

    ge