Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

global countdown timer help please?

so ive been trying to make a global countdown timer that is in sync with all players, and i dont know why but it just doesnt work

-- server script
local event = Instance.new("RemoteEvent")
event.Parent = game.Workspace
event.Name = "UpdateText"
game.Workspace.UpdateText:FireAllClients()

-- local script
local client = game.Players.LocalPlayer
local playergui = client.PlayerGui
local event = game.Workspace:FindFirstChild("UpdateText")
event.OnClientEvent:connect(function()
for i=850,0,-1 do 
	wait(1)
    playergui.ScreenGui.Frame.TextLabel.Text = ("Time left: "..i)
end
end)

1 answer

I would send the timer on the server rather than the client

Server

local event = game:GetService("ReplicatedStorage"):FindFirstChild("UpdateText")
-- I would put the event in ReplicatedStorage so it's filtering enabled
local timeLength = 850

for i=timeLength,0,-1 do
	wait(1)
	event:FireAllClients(i)
end


Client

local event = game:GetService("ReplicatedStorage"):FindFirstChild("UpdateText")
-- I would put the event in ReplicatedStorage so it's filtering enabled
local  client = game.Players.Localplayer
local playergui = client.PlayerGui


event.OnClientEvent:Connect(function(time)
	playergui.ScreenGui.Frame.TextLabel.Text = ("Time left: " .. time)
end)


This should keep all clients in sync with each other by firing all the clients at the same time

This discussion is preserved as it was. New answers, comments, and votes are closed.