Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Any way to pause code until event is fired?

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

✓ Accepted answer

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

2 comments

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.

0

np

This discussion is preserved as it was. New answers, comments, and votes are closed.