We're trying to make a game with a timer that displays milliseconds, seconds, and minutes. To make it count properly, we're trying to use a method to calculate delta time, but we're having trouble. Technically, it runs fine at a normal speed, but on lower FPS, the timer displays incorrectly, in top of it having the potential to cause quite a bit of lag. I think the script is unoptimized. Is there a better way to handle this? (Also, preferably, is there a way to make the milliseconds count up to only 28 before changing the seconds? But still have it be a second in real-time? Very specific request, I know. The big thing here is the optimization and getting this to run better on lower-end devices.)

wait(5)
local runService = game:GetService("RunService")
local renderStep = runService.RenderStepped
local timer = 0
local min = 0
local hour = 0

local function Timer()
    local delta = renderStep:Wait()
    local sec = math.floor(timer + 0.5)
    timer = timer + (delta * 100)
    if sec >= 100 then
        timer = 0
        min = min + 1
    elseif min == 60 then
        min = 0
        hour = hour + 1
    end
    if sec <=9 and min <=9 and hour<=9 then
        script.Parent.Text = "0"..hour.."'0"..min.."'0"..sec..""
    elseif hour<=9 and min<= 9 then
        script.Parent.Text = "0"..hour.."'0"..min.."'"..sec..""
    elseif hour<=9 then
        script.Parent.Text = "0"..hour.."'"..min.."'"..sec..""
    else
        script.Parent.Text = " "..hour.."'"..min.."'"..sec..""
    end
end

runService:BindToRenderStep("Timer", Enum.RenderPriority.First.Value, Timer)

Thanks!