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

How to stop a script from repeating?

Asked by 10 years ago

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"
--------------------------------------------------------------------------------------------
0
This script does not repeat. It only counts down once. BlueTaslem 18071 — 10y
0
hmmm, it repeated for me?? NinjoOnline 1146 — 10y
0
There must be something else within the script causing the repetition :] ImageLabel 1541 — 10y
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 NinjoOnline 1146 — 10y
View all comments (7 more)
0
Remove the infinite while loop. That's why it repeats............... NotsoPenguin 705 — 10y
0
^ ImageLabel 1541 — 10y
0
so what do i get rid of?? NinjoOnline 1146 — 10y
0
Ok I got it, but after the countdown the map dosent load NinjoOnline 1146 — 10y
0
Can you please update your post with the full script. NotsoPenguin 705 — 10y
0
Updated and it dosent repeat anymore, I just need it to then after the countdown pick a random map from the serverstorage NinjoOnline 1146 — 10y
0
0 player llermanlol 0 — 6y

2 answers

Log in to vote
0
Answered by 10 years ago
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..

0
It repeats :/ NinjoOnline 1146 — 10y
Ad
Log in to vote
0
Answered by 10 years ago

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

Answer this question