I need to make a round timer for my game, something that lasts around 10 minutes (600 seconds).
I’ve been trying to be courteous about translating information between the server and the client to prevent lag, which is why I came here to ask if I should have the server list the time, and then fire to all clients what the current time is.
Here’s what I mean:
local currentTick = tick()
while true do
wait(1)
local Time = Tick() - currentTick
TellTime:FireAllClients(Time)
end
Is this method much more preferable than to just have the client do this on its own? Would it be laggier but worth doing?
This method does work and allows the client to only know what is given to it. I wouldn’t use an attribute for this only because you would still be leaving that open for anyone to change via the client (which could be troublesome if you have any code bound to the timer in a local script).
Additionally, if you want to add something extra to your code, you could round the time elapsed (which you referred to as the variable ‘Time’) to the nearest whole number.
local roundValue = function(value)
return math.floor(value + .5)
end
local Time = roundValue(tick() - currentTick)
This just makes it so you aren’t sending the client a number with a long decimal. Besides that, this code ultimately performs how you would want it to.