I'm currently working on a game entitled "Color Rush," a round based game, and I'm currently working on the timer for when the round should end. My current script is as follows:
local Timer = game.StarterGui.ScreenGui.Timer for i=120, 1, -1 do Time = (tostring(math.floor(i / 60))..":"..tostring(i % 60)) Timer.Text = Time wait(1) end
After some troubleshooting, I've found that it's counting down, so the timer is working in the script, but it's not updating the timer to match. Why is that?
The reason it doesn't update is because when a player joins a game, the contents of the StarterGui are copied into their PlayerGui. It's the contents of the PlayerGui that are shown, not the StarterGui. A quick fix would be:
for i=120, 1, -1 do local Time = (tostring(math.floor(i / 60))..":"..tostring(i % 60)) for i, v in ipairs(game.Players:GetChildren()) do v.PlayerGui.ScreenGui.Timer.Text = Time end wait(1) end
Because you are using the 'StarterGui' which is does not hold the player gui.
To access the player gui from the server
local plrGui = game.Players.[Some player name].PlayerGui
From a LocalScript
local plrGui = game.Players.LocalPlayer.PlayerGui