Hey guys I need ya'll help. So let's say I have a script like this running:
script.Parent.Event:connect(function() print("Starting") wait(350) --Do more stuff. end)
But when it is waiting, let's say people lost the game and I don't want the script to run anymore and I want it to stop and go all the way back to the beggining.
How do I do that?
I'm not sure if you use return
but I don't know how to use return
anyways..
Note:Making a game where you have to survive until rescue arrives but when the players LOSE the game the script still runs and the bus still is active. How do i stop that?
I really would apreciate who would help me with this
As Nikkulaos said, you can create a variable that you set to true after everyone has lost.
At the top of the script, you can go:
local stopRound = false
Then, the round script can look something like:
stopRound = false local roundTime = 350 for i = roundTime,0,-1 do if stopRound == true then break end wait(1) end
And when all the players have lost, you can simply go:
stopRound = true
Well, I would recommend a 'if' statement. So
local EventRan = false; script.Parent.Event:connect(function() if not EventRan then EventRan = true print("Starting") wait(350) --Do more stuff. end end)