Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Why do these values not floor properly?

Asked by 3 years ago
Edited 3 years ago

I'm trying to make a timer that changes a value in the Player instance every second but the values don't floor properly

repeat
    wait()
until game:IsLoaded()
game.Players.LocalPlayer:WaitForChild("hours")
game.Players.LocalPlayer:WaitForChild("minutes")
game.Players.LocalPlayer:WaitForChild("seconds")
wait(1)
game.Workspace.Wheel.Info.SurfaceGui.time.hours.Value = game.Players.LocalPlayer.hours.Value
game.Workspace.Wheel.Info.SurfaceGui.time.minutes.Value = game.Players.LocalPlayer.minutes.Value
game.Workspace.Wheel.Info.SurfaceGui.time.seconds.Value = game.Players.LocalPlayer.seconds.Value
while wait(1) do
    currenttime = math.floor(game.Workspace.Wheel.Info.SurfaceGui.time.hours.Value * 3600 + game.Workspace.Wheel.Info.SurfaceGui.time.minutes.Value * 60 + game.Workspace.Wheel.Info.SurfaceGui.time.seconds.Value)
    currenttime = currenttime - 1
    h = math.floor(currenttime / 3600)
    m = math.floor(currenttime / 60 - 60 * h)
    s = math.floor(currenttime - 60 * m)
    game.Workspace.Wheel.Info.SurfaceGui.time.Text = "Time left until next free spin: "..h..":"..m..":"..s
    game.Workspace.Wheel.Info.SurfaceGui.time.hours.Value = h
    game.Workspace.Wheel.Info.SurfaceGui.time.minutes.Value = m
    game.Workspace.Wheel.Info.SurfaceGui.time.hours.Value = s
    game.ReplicatedStorage.thetime:FireServer(h, m, s)
end

Edit1: I printed the values and they come out negative? values -1 59 -3541 values -3541 58 -12747541 values -12747541 57 -45891147541 aaand somehow they got multiplied

1 answer

Log in to vote
0
Answered by 3 years ago

I figured it out I didn't format them properly!

h = math.floor(currenttime / 3600)
m = math.floor(currenttime / 60 % 60)
s = math.floor(currenttime % 60)
Ad

Answer this question