I'm trying to make a script that waits until a certain function fires. Is this possible?
Example of what i'm talking about:
repeat wait() until ManualTrigger:Connect() Part = Instance.new("Part") Part.Parent = game.Workspace ManualTrigger = game.ReplicatedStorage.ManualTrigger.OnServerEvent:Connect(function() print("Fired") end)
OR
spawn(function() while true do wait() if ManualTrigger:Connect() then print("ManualTrigger fired.") end end end) ManualTrigger = game.ReplicatedStorage.ManualTrigger.OnServerEvent:Connect(function() print("Fired") end)
All help is appreciated.
You can make a variable and set it to true as soon as the event is fired, and make the loop wait until it's equal to true like this
local Fired = false game.ReplicatedStorage.ManualTrigger.OnServerEvent:Connect(function() print("Fired") Fired = true end) repeat wait() until Fired == true Part = Instance.new("Part") Part.Parent = game.Workspace