Having Problems with making Server Timer

Hi Everyone!

Today i am trying to make Server Timer for my game and having problems with that

What i did: i made remote event for that and firing for all clients here is the code

local timerevent = game.ReplicatedStorage:FindFirstChild("TimerEvent")

local towergenerator = game.ReplicatedStorage:FindFirstChild("TowerGenerator")

local seconds = workspace:FindFirstChild("Timer").Seconds.Value
local minutes = workspace:FindFirstChild("Timer").minutes.Value

local plr = game.Players.LocalPlayer
local gui = plr.PlayerGui:FindFirstChild("TimeGui")
	if seconds <= 0 then
		minutes -= 1
		seconds = 59
		seconds -= 1
	if seconds <= 9  then
		gui:FindFirstChild(text).Text = tostring(minutes)..":0"..tostring(seconds)
		gui:FindFirstChild(text).Text = tostring(minutes)..":"..tostring(seconds)



Edit: Output is Argument 1 is missing

gui:FindFirstChild(text).Text = tostring(minutes)…“:”…tostring(seconds)
gui:FindFirstChild(text).Text = tostring(minutes)…“:0”…tostring(seconds)
This Lines

What exactly is the problem? Your post doesn’t mention what isn’t working.

I did notice you used “-=” and I do not believe that works in Lua. Try “minutes = minutes - 1” and similar for any other case you use “-=”.

Actuallly, compound assignments are possible in Luau (Roblox’s version of the Lua programming language). Luau Recap: June 2020

The issue is that you’re doing gui:FindFirstChlld(text), and text is not a string. If the text-label’s name is text, then it should be gui:FindFirstChild("text").

I would just handle the seconds on the server, and let the client manage making minutes and seconds from that. I would just have a number-value called Timer in replicated storage that holds the amount of seconds in the timer. We can use string formatting to form minutes and seconds from that. I would also use WaitForChild as opposed to FindFirstChild, as not everything may have loaded before the script.

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Players = game:GetService("Player")

local timerEvent = ReplicatedStorage:WaitForChild("TimerEvent")
local timerIndicator = ReplicatedStorage:WaitForChild("Timer")

local localPlayer = Players.LocalPlayer
local playerGui = localPlayer:WaitForChild("PlayerGui")
local timeGui = playerGui:WaitForChild("TimeGui")
local timeLabel = timerGui:WaitForChild("Text")

function formatTime(seconds)
    return string.format("%d:%02d", math.floor(seconds / 60), seconds % 60)

function updateTime()
    local timerValue = timerIndicator.Value or 0
    timeLabel.Text = formatTime(timerValue)


The time formatted is from here: