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

Script doesn't repeat when ended?

Step = 0
Counting = true
GuiWall = workspace.Spawn.GuiPart
players = #game.Players:GetPlayers()
crashDelay = 0.0001
killDis = 5
winDetection = true
InGame = false
LightWins = workspace.GameScripts.Winsystem.TLW
RunnersWin = workspace.GameScripts.Winsystem.TRW
SpawnPart = workspace.GameScripts.SpawnPart
print("running")
ready = true
Debounce = true
Debounce2 = false

repeat
	wait(crashDelay)
	if Debounce == true then
		players = #game.Players:GetPlayers()
		wait(crashDelay)
	
		if players < 2 and InGame == false then
			GuiWall.SurfaceGui.Players.Text = ("Players: "..tostring(#game.Players:GetPlayers()))
			GuiWall.SurfaceGui.Red.Text = "Not enough players"
	
		elseif players >= 2 and InGame == false then
			GuiWall.SurfaceGui.Players.Text = ("Players: "..tostring(#game.Players:GetPlayers()))
			GuiWall.SurfaceGui.Red.Text = "Waiting for a game to begin"
		
			InGame = true
			ready = true
		
		
		elseif InGame == true then
			wait(3)
			GuiWall.SurfaceGui.Players.Text = "Starting in"
			GuiWall.SurfaceGui.Red.TextColor3 = BrickColor.Green().Color
			GuiWall.SurfaceGui.Red.Text = "10"
			wait(1)
				GuiWall.SurfaceGui.Red.Text = "9"
			wait(1)
			GuiWall.SurfaceGui.Red.Text = "8"
			wait(1)
			GuiWall.SurfaceGui.Red.Text = "7"
			wait(1)
			GuiWall.SurfaceGui.Red.Text = "6"
			wait(1)
			GuiWall.SurfaceGui.Red.Text = "5"
			wait(1)
			GuiWall.SurfaceGui.Red.Text = "4"
			wait(1)
			GuiWall.SurfaceGui.Red.Text = "3"
			GuiWall.SurfaceGui.Red.TextColor3 = BrickColor.Red().Color
			wait(.5)
			GuiWall.SurfaceGui.Red.TextColor3 = BrickColor.Green().Color
			wait(.5)
			GuiWall.SurfaceGui.Red.Text = "2"
			GuiWall.SurfaceGui.Red.TextColor3 = BrickColor.Red().Color
			wait(.5)
			GuiWall.SurfaceGui.Red.TextColor3 = BrickColor.Green().Color
			wait(.5)
			GuiWall.SurfaceGui.Red.Text = "1"
			GuiWall.SurfaceGui.Red.TextColor3 = BrickColor.Red().Color
			wait(1)
			GuiWall.SurfaceGui.Red.Text = "Starting"			
			GuiWall.SurfaceGui.Players.Text = ""	
			wait(1)
			GuiWall.SurfaceGui.Red.Text = "Game is currently in progress..."
			GuiWall.SurfaceGui.Players.Text = ""
			print("InGame")	
		
			for i,plr in pairs(game.Players:GetPlayers()) do
				plr.Team = game.Teams.Runners
			end
		
			TheLight = game.Players:GetPlayers()[math.random(1,#game.Players:GetPlayers())]
			TheLight.Team = game.Teams.TheLight
		
			for i,v in pairs(game.Teams.Runners:GetPlayers()) do
				v.Character.HumanoidRootPart.CFrame = CFrame.new(52, 585.896, 3383)
			end
			for i,r in pairs(game.Teams.TheLight:GetPlayers()) do
				r.Character.HumanoidRootPart.CFrame = CFrame.new(-267, 586, 3044)
				wait()
				r.Character.Humanoid.WalkSpeed = 0
				wait(5)
				r.Character.Humanoid.WalkSpeed = 16
			end
		ready = true
		Debounce = false
		repeat
wait(crashDelay)
if winDetection == true then
			print(ready)
			wait()
			_G.LightK = 1
			LightPlrs = #game.Teams.TheLight:GetPlayers()
			RunnersPlrs = #game.Teams.Runners:GetPlayers()
			
			if LightPlrs == 0 and ready == true then
				ready = false
				print("The runners win")
				for i,v in pairs(game.Players:GetPlayers()) do
					local RW = RunnersWin:Clone()
					RW.Parent = v.PlayerGui
					v.Character.HumanoidRootPart.CFrame = SpawnPart.CFrame
					v.Team = game.Teams.Killed
					Debounce2 = true

				end
			
			elseif RunnersPlrs == 0 and ready == true then
				ready = false
				print("The Light wins")
				for i,v in pairs(game.Players:GetPlayers()) do
					local LW = LightWins:Clone()
					LW.Parent = v.PlayerGui
					v.Character.HumanoidRootPart.CFrame = SpawnPart.CFrame
					v.Team = game.Teams.Killed
					Debounce2 = true
					print("debouncing")
				end
			if Debounce2 == true then
				winDetection = false
				GuiWall.SurfaceGui.Red.Text = "Resetting"
				GuiWall.SurfaceGui.Players.Text = ""
				wait(5)
				GuiWall.SurfaceGui.Red.Text = "Wait"
				GuiWall.SurfaceGui.Players.Text = "10"
				wait(1)
				GuiWall.SurfaceGui.Players.Text = "9"
				wait(1)
				GuiWall.SurfaceGui.Players.Text = "8"
				wait(1)
				GuiWall.SurfaceGui.Players.Text = "7"
				wait(1)
				GuiWall.SurfaceGui.Players.Text = "6"
				wait(1)
				GuiWall.SurfaceGui.Players.Text = "5"
				wait(1)
				GuiWall.SurfaceGui.Players.Text = "4"
				wait(1)
				GuiWall.SurfaceGui.Players.Text = "3"
				wait(1)
				GuiWall.SurfaceGui.Players.Text = "2"
				wait(1)
				GuiWall.SurfaceGui.Players.Text = "1"
				wait(1)
				GuiWall.SurfaceGui.Players.Text = ""
				wait(1)		
				GuiWall.SurfaceGui.Red.Text = "Done!"
				wait(2)
				GuiWall.SurfaceGui.Red.Text = "Starting again"
				wait(2)
				
				Debounce = true
				Debounce2 = false
				InGame = false
			end
			end
end
		until false

		end
		end
until Counting == false	

it should repeat where you can see 'Debounce = true ' at the end of the script :/

2 comments

0

Repeat loops don't repeat once its condition is met, try using a while loop, or maybe even a while loop ontop of the repeat loop

0

Did you try looking for any possible errors?

1 answer

Try a while true do loop or a while wait(TIME HERE) do

3 comments

0

still doesn't repeat the code =/

0

There is no way that can happen. Are you breaking the code at some point? If you break the code, it only loops back when called.

0

Or do a function like function loop() and then call it in a while true loop.

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