Ad
Log in to vote
0

Any way to pause code until event is fired?

Asked by 18 days 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 17 days 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 61 — 17d
0
np MOJANGcreator091 45 — 15d
Ad
Log in to vote
0
Answered by 18 days ago

Maybe this could help Dev Post

0
I tried that already, it was the third thing I listed that didn’t work. manith513 61 — 17d

Answer this question