Is there any way for a script to know when a function connects?

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 use the Event:wait() command to make the script wait until that event is ran.

For example, game.Players.PlayerAdded:wait() waits until a player is added before continuing with the rest of the script

1 Like