The following script rounds the health value on the GUI to a whole number and displays it. Right now the script is setup to be in a directory like this:
ScreenGui
\Script
\TextBox
Meaning that Script.Parent = ScreenGui, and TextBox.Parent = ScreenGui
______
SCRIPT
______
--Prsho
function round(val, decimal) --rounds number to avoid a ton of decimals
if (decimal) then
return math.floor( (val * 10^decimal) + 0.5) / (10^decimal)
else
return math.floor(val+0.5)
end
end
while true do
wait()
local player = script.Parent.Parent.Parent
if player.Character.Humanoid ~= nil then
local health = player.Character.Humanoid.Health
local rounders = round(health) --Calls function "round" to round Health value
script.Parent.TextBox.Text = rounders
end
end |