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

How do I get my code to not stop after this one part?

Asked by 4 years ago
local s = script.Stat
local vals = game.ReplicatedStorage.vals
t = 0
while true do
    local plrs = game.Players:GetChildren()
    if #plrs > 0 then
    t = 15
    repeat
        t = t-1
        s.Value = "Intermission.. "..t
        wait(1)
    until t == 0
    s.Value = "Get Ready to Wipeout!"
    wait(2)
    local mapselect = game.ReplicatedStorage.Games:GetChildren()
    local choose = math.random(1,#mapselect)
    curnum = 0
    for i =1,#mapselect do
        curnum = curnum +1
        if curnum == choose then
            mapselect[i]:Clone().Parent = workspace
            curmap = mapselect[i].Name
            s.Value = "The next course is "..mapselect[i].Name
        end
    end
    wait(3)
    local plrs = game.Players:GetChildren()
    for i = 1,#plrs do
        local num = math.random(1,10)
        plrs[i].Character.Head.CFrame = CFrame.new(workspace.Teleports["Part"..num].Position)
        plrs[i].Character.Parent = workspace.Ingame
    end
    t = 0
    repeat
        t = t+1
        s.Value = t..
        wait(1)
    until t ==300 or vals.Winner.Value ~= "" or #ingame == 0
    if vals.Winner.Value ~= "" then
        s.Value = vals.Winner.Value.. " has won!"
        game.Players[vals.Winner.Value].leaderstats.Points.Value =game.Players[vals.Winner.Value].leaderstats.Points.Value +50
        game.Players[vals.Winner.Value].leaderstats.Wins.Value =    game.Players[vals.Winner.Value].leaderstats.Wins.Value +1
        vals.Winner.Value = ""
    else
        s.Value = "No one has won!"
    end
    wait(3)
    local ingame = workspace.Ingame:GetChildren()
    for i =1,#ingame do
        local plr = game.Players:GetPlayerFromCharacter(ingame[i])
        plr:LoadCharacter()

    end
    workspace[curmap]:Destroy()
    else
        s.Value = "Waiting for Players..."
        wait(1)
        end
end

Okay, so I looked up coding tutorials and I tried coding a minigame place. However when it gets to this part, it always freezes the timer and the code stops. I don't really understand why though.

repeat t = t+1 s.Value = t.. wait(1)

0
repeat MutantJonny 0 — 4y
0
Any errors in the output? Prestory 1395 — 4y
0
use coroutines. greatneil80 2647 — 4y

2 answers

Log in to vote
0
Answered by 4 years ago

you cant put 2 dots after a value since 2 dots means followed by, it puts in the value for t but then it wants more due to those dots so if you want to have 2 dots in your value then you need to do the following s.Value == t..".."

Ad
Log in to vote
0
Answered by
A_thruZ 29
4 years ago

I would use a while loop for this occasion. I developed a similar place, in which players would participate in various minigames, with a timer counting down each one. I used a while loop for that. Here's your code, for the timer, with a while loop instead.

local plrs = game.Players:GetChildren()
    if #plrs > 0 then
    t = 15
    while t ~= -1 do
        t = t-1
        s.Value = "Intermission.. "..t
        wait(1)
    end

Try that, and I hope it helps!

Answer this question