How to get rid of decimal on gui

For some reason the gui is showing decimals after taking damage?

Heres the script:

local bar = script.Parent:WaitForChild("Bar")
local hpText = script.Parent:WaitForChild("HP")
local player = game.Players.LocalPlayer
repeat wait() until player.Character
local connection_health
local connection_max_health
local character = player.Character

local function update()
	local humanoid = character:WaitForChild("Humanoid")
	bar:TweenSize(UDim2.new(humanoid.Health / humanoid.MaxHealth, 0, 1, 0), Enum.EasingDirection.In, Enum.EasingStyle.Quint, 1, true)
	hpText.Text = humanoid.Health .. "/" .. humanoid.MaxHealth .. " HP"
end

local function setConnections()
	local humanoid = character:WaitForChild("Humanoid")
	connection_health = humanoid:GetPropertyChangedSignal("Health"):Connect(update)
	connection_max_health = humanoid:GetPropertyChangedSignal("MaxHealth"):Connect(update)
	update()
end

player.CharacterAdded:Connect(function(char)
	character = char
	if connection_health then connection_health:Disconnect() end
	if connection_max_health then connection_max_health:Disconnect() end
	setConnections()
end)

setConnections()
1 Like

It’s probably because the damage amount the player took wasn’t an integer. If you want, you can round the decimal on the UI to the nearest one.

You can do math.ceil(number) which rounds the decimal high or math.floor(number) which does the opposite.

1 Like

where would I put this inside the script???

Here:
Change this

hpText.Text = humanoid.Health .. "/" .. humanoid.MaxHealth .. " HP"

to this

hpText.Text = math.floor(humanoid.Health) .. "/" .. humanoid.MaxHealth .. " HP"

You can to math.ceil to make the number round higher.