Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Why do these values not floor properly?

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

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)

This discussion is preserved as it was. New answers, comments, and votes are closed.