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

How to stop previous function, whe second function is started?

rs = game:GetService("ReplicatedStorage")

rs.RemoteEvents.FireAnigilation.OnServerEvent:Connect(function(player, Mouse)
	print("LoL, u will not stop me")
	wait(10)
	print("U lose!")
end)
rs.RemoteEvents.FireAnigilationEnd.OnServerEvent:Connect(function(player, Mouse) 
	print("Yey, i win!")
end)

1 answer

✓ Accepted answer

You have to have use a variable to keep track of whether the first function should continue or not. For instance, you might set shouldContinue = true when the first function starts running, then shouldContinue = false if it should be cancelled, and then the first function should run if not shouldContinue then return end every time the variable may have changed (after every yield/wait)

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