Im currently working on a game that uses a distance travelled counter, but i ran into a problem where
the counter have a lot of decimal points in it. I’ve tried math.ceil() and math.floor() but it doesnt seem to
work or maybe im doing something wrong.
The script:
local TotalStudsWalked = {}
while wait do
for i,Player in pairs(game.Players:GetPlayers()) do
if Player.Character then
local Humanoid = Player.Character:FindFirstChildOfClass("Humanoid")
if Humanoid.MoveDirection.Magnitude > 0 then
if OldPosition[Player.UserId] then
local newDistanceTravelled = (Humanoid.RootPart.Position - OldPosition[Player.UserId]).Magnitude
TotalStudsWalked[Player.UserId] = TotalStudsWalked[Player.UserId] + newDistanceTravelled
--math.round(script.Parent.Text)
script.Parent.Text = script.Parent.Text + (newDistanceTravelled / 5)
OldPosition[Player.UserId] = Humanoid.RootPart.Position
else
TotalStudsWalked[Player.UserId] = 0
OldPosition[Player.UserId] = Humanoid.RootPart.Position
end
end
end
end
wait(0.1)
end```