Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How to make this script reset?

Asked by
wjs3456 90
10 years ago

I want to make a script go back to the beginning after it has run through all the functions and waited. I would assume you would use a while loop but I'm not sure how to make it go to the beginning if this script is true:

function waitforwinner()
if #getTeam(Game.Teams.Survivors) == 0 then
    m = Instance.new("Message",Workspace)
    m.Text = "The final survivor has been infected. Infected win!"
    wait(3)
    m:Destroy()         
    --Put reset part here
end
end

Thanks!

0
No it is only a snippet with the if statement that is making it tricky .The entire script is about 100 lines long wjs3456 90 — 10y

2 answers

Log in to vote
2
Answered by 10 years ago

If I correctly understand what you're doing, it's pretty easy. Basically just call the function again from inside the function. So:


function waitforwinner() if #getTeam(Game.Teams.Survivors) == 0 then m = Instance.new("Message",Workspace) m.Text = "The final survivor has been infected. Infected win!" wait(3) m:Destroy() waitforwinner() end end

--MightyWanderer

0
This worked :) wjs3456 90 — 10y
Ad
Log in to vote
-1
Answered by
yurhomi10 192
10 years ago

easy, make a while loop.

for example,

a = 1

while a == 1 then 
function()
wait()
end
0
That's the hard part. How do I make it start over again? wjs3456 90 — 10y
0
it starts over on its own, thats why it runs infinitely. if you did while true do print("hey") wait(1) end it will print hey every second forever, granted you use atleast a wait. yurhomi10 192 — 10y

Answer this question