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

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

Asked by 4 years ago

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

0
Script got all messed up here, this is a pastebin to the script i made https://pastebin.com/ViBmMyTf sadaiden03 5 — 4y

1 answer

Log in to vote
0
Answered by 4 years ago

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
0
Thank You!! sadaiden03 5 — 4y
Ad

Answer this question