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

showing players health with one decimal?

Hi I am trying to make it show the players health with out 20 decimals. Can you help?~~~~~~~~~~~~~~~~~ humanoid = game.Players.LocalPlayer.Character.Humanoid

while true do wait() function round1Place(x) return (x + 0.5 - (x + 0.5) % 1) end script.Parent.Text = humanoid.Health end


1 answer

✓ Accepted answer

First of all, let's make sure your script doesn't run before the LocalPlayer loads. To do that, we can use the following loop: repeat wait() until game.Players.LocalPlayer.Character;

Next, I inserted a function called round1Place, that you call with round1Place(NUMBERHERE) and it returns the same number but rounded to the first decimal point.

For example:

function round1Place(x)
	return (x + 0.05 - (x + 0.05)  % .1)
end
local r = 3.32
r = round1Place(r)
print(r) --> 3.3

print(round1Place(2.25)) --> 2.3

Put it all together:

repeat wait() until game.Players.LocalPlayer.Character;
humanoid = game.Players.LocalPlayer.Character.Humanoid
function round1Place(x)
	return (x + 0.05 - (x + 0.05)  % .1)
end

while wait() do  
	script.Parent.Text = round1Place(humanoid.Health)
end

2 comments

0

What changes did you make? Explain what you did.

0

@TheContinentOfEurope Edited

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