How to use a local script to trigger another local script when it's finished?

so basically I am trying to make a local script trigger another script when it has finished with its own stuff ykyk, like i dunno what else to say so :pray::sob: i tried reading docs but im too slow to understand ig, and i even asked the roblox assistant ai but it’s not that much of help tbh

BindableEvents would probably be the best option here, but you could probably use a RemoteEvent as well .

It really depends on what you mean. If you mean communication between two local scripts under the same client then you need BindableEvents. If you mean communication between two local scripts of two different clients you need RemoteEvents and a server script in between for relaying information.

under the same client, so remote event is what i need i think? are you able to provide me an example so I can understand how to create my own?

here is what I am attempting to do, and I wonder if there is an easier way:

player will click button1 that will run through script 3, then button 1 will tween out as well as run the script under it (script 1), once script 1 is finished it will trigger script 2 which will disable script 1 and change the appearance of button 1 as needed (I need to use button 1, I cannot use another button for certain reasons) after script 2 disables script 1, script 2 will then tween the button back in and since its still button one, script 3 will run through again, though the other way around (its kind of like a on/off script, first click is on, second is off).

this probably sounds kind of dumb but i promise this is how it needs to go to work with what im doing lol, this is only the surface of this entire thing im doing… i hope i explained it well :sob:

  1. Create an Event:

    • In the script that you want to trigger, create an event using the Instance.new function.
    • For example, you can create an event named “MyEvent” like this: local myEvent = Instance.new("BindableEvent")
  2. Fire the Event:

    • When the first script has finished its tasks and you want to trigger the second script, you can fire the event.
    • Use the :Fire() method on the event object you created.
    • For example, to fire “MyEvent”: myEvent:Fire()
  3. Connect the Event:

    • In the second script, you need to connect to the event and define what happens when it’s fired.
    • Use the :Connect() method on the event object to add a function that will be executed when the event is fired.
    • For example, to connect to “MyEvent” and execute a function called “MyFunction”: myEvent.Event:Connect(MyFunction)
  4. Define the Function:

    • In the second script, define the function that will be executed when the event is fired.
    • For example: local function MyFunction() print("Event fired!") end
1 Like