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

How to make this script reset?

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!

1 comment

0

No it is only a snippet with the if statement that is making it tricky .The entire script is about 100 lines long

2 answers

✓ Accepted answer

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

1 comment

0

This worked :)

easy, make a while loop.

for example,

a = 1

while a == 1 then 
function()
wait()
end

2 comments

0

That's the hard part. How do I make it start over again?

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.

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