For some reason, when my timer script goes past 1:00 minute, it glitches and starts counting a bunch of 9s and 0s.
How can I fix this?
local timerLabel = script.Parent
local runserv = game:GetService("RunService")
function setTime(Seconds) --thanks to D0RYU
local SS = Seconds % 60
local MM = (Seconds - SS) / 60
return MM..":"..(10 > SS and "0"..SS or SS)
end
runserv.Heartbeat:Connect(function()
local song = workspace.chosenSong.Value
local timer = (setTime(math.floor(((song.TimePosition*100)+0.5))/100) .. "/" .. setTime(math.floor(((song.TimeLength*100)+0.5))/100))
timerLabel.Text = timer
end)
Hey, I think I figured out the solution to your problem. Turns out you need math.floor() on the SS and MM too.
function setTime(Seconds) --thanks to D0RYU
local SS = math.floor(Seconds % 60)
local MM = math.floor((Seconds - SS) / 60)
return MM..":"..(10 > SS and "0"..SS or SS)
end