I am trying to make a milliseconds timer using localscript, but it seems to be skipping 0.1 second sometimes.
Here is my script:
wait(1) local StartTick = tick() while true do local Second = tick() - StartTick Second = Second * 10 print("original second: "..Second) Second = math.floor(Second) Second = Second / 10 script.Parent.Timer.TextLabel.Text = Second print("fixed second: "..Second) wait(0.1) end
I put print for original second and fixed second, here's the output: https://i.gyazo.com/afe8fc2411ea85a8f473dac7c7a4c6a0.png
problem: you're doing it in a while do
loop, which means it's not recommended to remove wait(0.1)
but the problems of skipping is in the wait()
at the bottom of your loop. try changing it to wait()
or RunService.Heartbeat:Wait()