Hi everyone!
I was making a timer that would count up by milliseconds (like a speedrun timer) when an event is fired. Here is the local script for that below:
local isRunning = false
local rs = game:GetService("RunService")
function round(num)
end
script.Parent.Start.Event:Connect(function()
if isRunning == false then
isRunning = true
local timer = script.Parent
while isRunning == true do
rs.Stepped:Connect(function(sec, _)
local miliseconds = math.floor(sec * 100)/100
local seconds = math.floor(sec)
local minutes = math.floor(sec / 60)*60
if miliseconds < 10 then
miliseconds = "0" .. tostring(miliseconds)
end
if seconds < 10 then
seconds = "0" .. tostring(seconds)
end
script.Parent.Text = minutes .. ":" .. seconds .. "." .. miliseconds
end)
end
end
end)
script.Parent.Stop.Event:Connect(function()
isRunning = false
script.Parent.Text = "00:00.00"
end)
When the event fires, so much lag happens that it can barely run, taking about 10 mins to stop entirely. On top of that, there are 4 places for digits (something like this -> 34:45.09.32, the extra ".32" at the end shouldn't be there) in the timer. Why does this lag happen, and why is the extra bit created?
Thanks in advance :)

1 comment
The thing about loops is that you must need a wait otherwise your studio will crash add a wait under all your loops i would say about 1 second.