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

My intermission timer automatically stops ticking, how can I fix this?

Asked by 3 years ago

I'm making an intermission for my round-based game. So, like any intermission, I have a timer GUI. It's supposed to tick down for 15 seconds and when it gets to 0, it will teleport all players to the map.

The problem is, the TextLabel which I set the text to display the intermission timer's value will automatically stop ticking at 14. Can someone help? Here's my code:

repstorage = game.ReplicatedStorage
timer = game.StarterGui.RoundTimer.TimerText

local intermission = Instance.new("IntValue")
    intermission.Name = "Intermission"
    intermission.Value = 15
    intermission.Parent = game.ReplicatedStorage

function countdown()
    repeat
        intermission.Value = intermission.Value - 1
        timer.Text = intermission.Value
            wait(1)
    until intermission.Value == 0

    if intermission.Value == 0 then
        intermission.Value = intermission.Value + 15
    end
end

repstorage.ChildAdded:Connect(countdown)

go easy on me

2 answers

Log in to vote
0
Answered by 3 years ago

You have to access the player's playerGui, not the starterGui!

Try this:

repstorage = game.ReplicatedStorage

local intermission = Instance.new("IntValue")
    intermission.Name = "Intermission"
    intermission.Value = 15
    intermission.Parent = game.ReplicatedStorage
function updateGui()
    for x,y in pairs(players) do -- goes thru all the players (x = key, y = the player)
        y.PlayerGui.RoundTimer.TimerText.Text = intermisson.Value -- Updates the gui
    end
end
function countdown()
    players = game.Players:GetChildren() -- I added this table of all the players
    repeat
        intermission.Value = intermission.Value - 1
        updateGui()
            wait(1)
    until intermission.Value == 0

    if intermission.Value == 0 then
        intermission.Value = intermission.Value + 15
    end
end

repstorage.ChildAdded:Connect(countdown)

Plz accept! (If it helped)

0
The starterGui won't change anything unless a player rejoins or dies R_LabradorRetriever 198 — 3y
0
This worked! Thanks for the help, and thanks for making it very clear. ;) jaackharm 42 — 3y
0
:D R_LabradorRetriever 198 — 3y
Ad
Log in to vote
0
Answered by
Aztralzz 169
3 years ago

Maybe try this, I have an intermission script and it works fine.

local timer = game.StarterGui.RoundTimer.TimerText

function intermission()
for i = 15,0,-1 do
timer.Text = ""..i..""
wait(1)
end)
while true do
intermission()
wait(1)
end

This should work. But it doesn't do it every time a player joins. Good Luck!

Answer this question