So I have a timer in my game and I tested going pretty much exactly the same speed until I touch the part that stops the timer and on studio the time was more but when I tested in game going the same exact speed it was like almost 5 seconds less?
The timer is on the server and I’m firing it every 0.01 seconds to all clients, also testing both times I was at the same starting position
while self.timer do
self.elapsedTime += 0.01
RemoteManager.Timer:FireAllClients(self.elapsedTime)
if self.elapsedTime > self.maxEventTime then
RemoteManager.TimerEnd:FireAllClients()
self:RemoveCurrentHeat()
break
end
task.wait(0.01)
end
Task.wait is dependent on fps and because Roblox studio uses your own PC as the server hoster your fps might be lower or higher than a Roblox-hosted server this might be your problem
So in that case what should I do because I already tried telling the clients to do their own loops while I calculate the elapsed time on the server and when it reaches a certain time tell all the clients to end their loops but, the client ones were out of sync
I mean most games have loops and timers, but answering your question i’m making a track game and I need a timer for it that im displaying on each players screen ( basically)
alright i fixed it, so instead of just updating the loop by 0.01 seconds, which can cause discrpancies in timing because of stuff like proccessing power, network latency and frame rate
I used a more accurate method to calculate the elapsed time which doesnt rely on a fixed increment but instead calculates the difference in time between each iteration using os.clock
while self.timer do
local currentTime = os.clock()
local deltaTime = currentTime - prevTime
self.elapsedTime += deltaTime
RemoteManager.Timer:FireAllClients(self.elapsedTime)
if self.elapsedTime > self.maxEventTime then
RemoteManager.TimerEnd:FireAllClients()
self:RemoveCurrentHeat()
break
end
prevTime = currentTime
task.wait(0.01)
end
@ali432567 Thank you for taking the time to reply, means alot!
The other issue is that since the way task.wait() is done the minimum time you can get with just task.wait is just .03 seconds, so using (.01) isn’t going to go any faster than (.03).