while true do
wait()
function round(n)
return n % 1 >= 0.5 and math.ceil(n) or math.floor(n)
end
round(game.Players.LocalPlayer.Character.Humanoid.Health)
end
Is supposed to keep the player's health as a rounded number. It doesn't work
while true do
wait()
function round(n)
return n % 1 >= 0.5 and math.ceil(n) or math.floor(n)
end
round(game.Players.LocalPlayer.Character.Humanoid.Health)
end
Is supposed to keep the player's health as a rounded number. It doesn't work
You need to assign the rounded value to the character's Health.
while true do
wait()
function round(n)
return n % 1 >= 0.5 and math.ceil(n) or math.floor(n)
end
game.Players.LocalPlayer.Character.Humanoid.Health = round(game.Players.LocalPlayer.Character.Humanoid.Health)
end
I've seen people here use this math.floor(n+.5).
From what I understand the number provided will add .5. If it does not break to a new number, then it will be completely rounded down to the lowest number.
Say I had .4. The code will add .5 making it .9 however since it was originally under the .5 mark, it will round down to 0. Now if I had .6, the code would add .5 making it 1.1. The code would then round it down to 1 which is where we wanted to round it.
However, ROBLOX will always be adding to the health if you took damage, unless you removed the recovery scripts.
Hope I helped.
while true do
wait()
function round(n)
return math.floor(n+.5)
end
game.Players.LocalPlayer.Character.Humanoid.Health = round(game.Players.LocalPlayer.Character.Humanoid.Health)
end
This discussion is preserved as it was. New answers, comments, and votes are closed.