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

Why am i getting stuck in a loop of the top part of my script?

I tried using this script to make the orange team die and spawn at their spawn point just as a start to what I'm doing. All goes fine and dandy up until my player dies they respawn and the game starting timer resets instead of using the round timer.

local s = script.Stat -- this is intermission t = 0 while true do t = 10 repeat t = t-1 s.Value = "Game Starting In "..t.." Seconds" wait(1) until t == 0 s.Value = "Game Starting" wait(2) for i, v in pairs(game.Teams.Orange:GetPlayers()) do v.Character.Head:Destroy() end end

wait(1) -- this is supposed to be in round s = 0 while true do s = 10 repeat s = s-1 s.Value = s.."Seconds Remain" wait(1) until s == 0 s.Value = "Defenders Win" end

1 comment

0

Script got all messed up here, this is a pastebin to the script i made https://pastebin.com/ViBmMyTf

1 answer

✓ Accepted answer

You would use break to exit from a loop. Simply insert break in the loop where you want to stop the loop.

I'll make an assumption and edit your script, placing break where I see fit.

local s = script.Stat
-- this is intermission
t = 0
while true do
	t = 10
	repeat
		t = t-1
		s.Value = "Game Starting In "..t.." Seconds"
		wait(1)
	until t == 0
	s.Value = "Game Starting"
	wait(2)
	for i, v in pairs(game.Teams.Orange:GetPlayers()) do
		v.Character.Head:Destroy()
	end
       break; -- stop loop here and continue with the script
end

wait(1)
-- this is supposed to be in round
s = 0
while true do 
	s = 10
	repeat
		s = s-1
		s.Value = s.."Seconds Remain"
		wait(1)
	until
	s == 0
	s.Value = "Defenders Win"
      break; -- stop loop here
end

1 comment

0

Thank You!!

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