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

How to stop a script from repeating?

I have this script which gives a countdown to the next round, but after it hits 1 it goess back to 9. How can I get it to stop and pick a random map once the clock hits 0??

--------------------------------------------------------------------------------------------	
if game.Workspace.MainText.Value == "MorePlayers" then
	script.Parent.Text = "You need 2 players to begin the game"
	script.Parent.Parent.Visible = true
elseif game.Workspace.MainText.Value == "GameBegin" then 
	script.Parent.Text = "Next round begins in:"
	script.Parent.Parent.Visible = true
--------------------------------------------------------------------------------------------		
	for i = 10,1, -1 do
		script.Parent.Parent.Timer.Text = i
		wait(1)
	end	
end
--------------------------------------------------------------------------------------------
game.Workspace.GameBegin.Value = "Begin"
--------------------------------------------------------------------------------------------

11 comments

0

This script does not repeat. It only counts down once.

0

hmmm, it repeated for me??

0

There must be something else within the script causing the repetition :]

0

-------------------------------------------------------------------------------------------- while true do if game.Workspace.MainText.Value == "MorePlayers" then script.Parent.Text = "You need 2 players to begin the game" script.Parent.Parent.Visible = true elseif game.Workspace.MainText.Value == "GameBegin" then script.Parent.Text = "Next round begins in:" script.Parent.Parent.Visible

0

Remove the infinite while loop. That's why it repeats...............

0

^

0

so what do i get rid of??

0

Ok I got it, but after the countdown the map dosent load

0

Can you please update your post with the full script.

0

Updated and it dosent repeat anymore, I just need it to then after the countdown pick a random map from the serverstorage

0

0 player

2 answers

✓ Accepted answer
for i = 10,1, -1 do
	script.Parent.Parent.Timer.Text = i
	wait(1)
end

maps = game.Lighting.Maps:GetChildren()
ranmap = math.random(1,#maps)
if ranmap == 1 then
	clonemap = game.Lighting.Maps.Map1:clone()
elseif ranmap == 2 then
	clonemap = game.Lighting.Maps.Map2:clone()
end

clonemap.Name = "Map"
clonemap.Parent = game.Workspace

I think that might work..

1 comment

0

It repeats :/

all you have to do is use a function instead like this

function choosemap()
your script
end
--then 
--the loop
while true do
choosemap()
end

i hope that helped

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