Ad
Log in to vote
0

Why won't this gui timer script work?

Asked by 7 years ago

In roblox studio it works all the way down to 0 but when I test it on a regular game it goes down a couple of seconds then it stops. Here's the code.

while wait(3) do
for i=300, 0, -1 do
game.StarterGui.SFTimer.TextLabel.Text = ("Time left: "..i)
wait(1)
end
end

1 answer

Log in to vote
0
Answered by
Hibobb 40
7 years ago

Why are you editing StarterGui? In order to change each player's gui you have to edit the one in each PlayerGui. Something along the lines of:

while wait(3) do
    for i = 300,0,-1 do
        for _,v in pairs(game.Players:GetPlayers()) do
            if v:FindFirstChild("PlayerGui") then--just a precaution
                v.PlayerGui.SFTimer.TextLabel.Text = "Time left: "..i
                wait(1)
            end
        end
    end
end
0
Another solution would be to control a single IntValue with a server Script then use a LocalScript in the guis to change their text. Perci1 4988 — 7y
0
The script works but it waits 3 seconds then it goes down Jupiturd 15 — 7y
0
Because you have the while wait(3) do Hibobb 40 — 7y
0
I changed it to while wait(1) do Jupiturd 15 — 7y
0
Thanks for the help i appreciate it Jupiturd 15 — 7y
Ad

Answer this question