#Timer showing negatives

1 messages · Page 1 of 1 (latest)

narrow viper
#

I am super confused. What is wrong with this? The timer is showing negatives, but different times in the negatives for different people.

local tst: NumberValue = plrs.LocalPlayer:WaitForChild("TowerStartTime")

local function formatCompletionTime(secondsFloat)
    local totalSeconds = math.floor(secondsFloat)
    local minutes = math.floor(totalSeconds / 60)
    local seconds = totalSeconds % 60
    local ms = math.floor((secondsFloat - totalSeconds) * 1000)
    return string.format("%02d:%02d.%03d", minutes, seconds, ms)
end

Timer.Text = formatCompletionTime((DateTime.now().UnixTimestampMillis - tst.Value) / 1000)
balmy shadow
#

@narrow viper put in ai

exotic silo
exotic silo
# narrow viper I am super confused. What is wrong with this? The timer is showing negatives, bu...
local plr = game:GetService("Players").LocalPlayer
local tst = plr:WaitForChild("TowerStartTime")

local function formatTime(n)
    local total = math.floor(n)
    local m = math.floor(total / 60)
    local s = total % 60
    local ms = math.floor((n - total) * 1000)
    
    return string.format("%02d:%02d.%03d", m, s, ms)
end

local elapsed = workspace:GetServerTimeNow() - tst.Value
Timer.Text = formatTime(math.max(0, elapsed))```
#

its because you were using DateTime lol