its way under the sound length is 0.235
It’s not gonna be annoying because the sound is not loud and there is gonna be music over it, but thank you for your help it works!
local run = game:GetService("RunService")
local sound = script.Sound --Put a sound instance inside the script named "Sound".
local label = script.Parent
local oldElapsed = 0
local function formatTime(currentTime)
local hours = math.floor(currentTime / 3600)
local minutes = math.floor((currentTime - (hours * 3600))/60)
local seconds = math.floor((currentTime - (hours * 3600) - (minutes * 60)))
local milliseconds = 1000 * (currentTime - math.floor(currentTime))
local format = "%02d:%02d:%02d:%03d"
return format:format(hours, minutes, seconds, milliseconds)
end
local function startTimer(currentTime)
run.Stepped:Connect(function(newElapsed, step)
if oldElapsed ~= math.floor(newElapsed) then
sound:Play()
end
oldElapsed = math.floor(newElapsed)
currentTime -= step
if currentTime <= 0 then
label.Text = "Timer has finished!"
return
end
label.Text = formatTime(currentTime)
end)
end
startTimer(10)
Here you go, it’ll only play once per second now.
13 Likes