Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Any way to pause code until event is fired?

Asked by
manith513 121
1 year ago

I have a script that fires an event, but I want that script to wait until a different event is fired. These are bindable events btw. I've tried wait(EventName.Event), repeat until EventName.Event, EventName.Event:Wait(). None of these are working. The other script is firing the event however, if I remove the Fire() from the other script the main script still doesn't wait for the event to be fired. If anyone has any ideas please let me know.

2 answers

Log in to vote
1
Answered by 1 year ago

detect remote fired documentation:

http://create.roblox.com/docs/scripting/events/remote-events-and-functions

local check_if_fired = 0

-- if fired then it should change check_if_fired to 1
--[[ if the different event is fired, try to detect it when it fires like this:
local differentevent = --the path of the different event
(on client)
    differentevent .OnClientEvent:Connect(function()
    check_if_fired = 1
        end)
(on server)
    differentevent .OnServerEvent:Connect(function()
    check_if_fired = 1
        end)
]]

if check_if_fired == 1 then
--the code here ( the line of code that you fire the remote)
end

hope this helped you

0
This technically could work, but it feels like more of a workaround rather than a direct solution using wait(), i think I would do repeat until check__fired == 1. I’ll still mark this as the answer since I can’t find anything else though. Thanks. manith513 121 — 1y
0
np MOJANGcreator091 60 — 1y
Ad
Log in to vote
0
Answered by 1 year ago

Maybe this could help Dev Post

0
I tried that already, it was the third thing I listed that didn’t work. manith513 121 — 1y

Answer this question