Hi, I've been having trouble with having my game timer show up on every player's screen. Can anyone help me with all the players seeing the same time? Here's my script that didn't work:
local timertag = Instance.new("NumberValue",workspace) timertag.Value = 200 timertag.Name = "TimerTag" function tag() timertag.Value = timertag.Value - 1 end repeat wait() until game:WaitForChild("Players") for _, player in pairs(game.Players:GetChildren()) do while timertag.Value > 0 do tag() player.PlayerGui.ScreenGui.TextLabel.Text = "Time left: "..timertag.Value wait(1) end end
Your issue is that you start looping through all players, but imidiately start the timer loop on first player.
Instead, you would want to start the timer loop and loop through every player for every second passed. It might sound slow, but it is really not.
local timertag = Instance.new("NumberValue",workspace) timertag.Value = 200 timertag.Name = "TimerTag" function tag() timertag.Value = timertag.Value - 1 end repeat wait() until game:WaitForChild("Players") while timertag.Value > 0 do -- Decrease time like you did tag() -- Now apply this change to every player for _, player in pairs(game.Players:GetChildren()) do player.PlayerGui.ScreenGui.TextLabel.Text = "Time left: "..timertag.Value end -- Only then wait wait(1) end
Edit: Sorry for accidentaly submit