Print function prints decimals too

Hello! I’m making a simple health bar script.

I would like to make it’s text get the first two numbers of the player’s health and not the decimals, so that it would look something like 55/100 instead of 55.21304…/100

Captura

This is the part of the script that changes the text

script.Parent.Parent.Health.Text = hum.Health.."/"..hum.MaxHealth

Yeah, that happens with health. You could try running the “unrefined” health through a math.floor() or math.ceil() then using those values as the humanoid’s health.

1 Like

For completeness, you can also have fine control over how numbers get turned into strings using string.format. In this case:

Text = string.format("%d/100", hum.Health)

This is useful when you want to do things like control exactly how many decimal places are shown, etc.

1 Like