I have this health bar script and for some reason it is showing decimals, I just want it to show whole numbers, can somebody please fix my script?
local greenFrame = script.Parent.Green
local label = script.Parent.TextLabel
local tweenService = game:GetService("TweenService")
local info = TweenInfo.new(.5,Enum.EasingStyle.Sine,Enum.EasingDirection.Out,0,false,0)
local lastHealth = 0
while wait(1) do
if game.Players.LocalPlayer.Character then
local currentHealth = game.Players.LocalPlayer.Character.Humanoid.Health
local newFrameSize = UDim2.new (currentHealth/100,0,1,0)
local tween = tweenService:Create(greenFrame,info,{Size=newFrameSize})
tween:Play()
if currentHealth > lastHealth then
for i = lastHealth, currentHealth, 1 do
label.Text = tostring(i).." / 100"
wait(1/(currentHealth-lastHealth))
end
else
for i = lastHealth, currentHealth, -1 do
label.Text = tostring(i).." / 100"
wait(1/(currentHealth-lastHealth))
end
end
lastHealth = currentHealth
end
end
local tweenService = game:GetService("TweenService")
local Players = game:GetService("Players")
local LocalPlayer = Players.LocalPlayer
local greenFrame = script.Parent.Green
local label = script.Parent.TextLabel
local info = TweenInfo.new(.5,Enum.EasingStyle.Sine,Enum.EasingDirection.Out,0,false,0)
local lastHealth = 0
while task.wait(1) do
if LocalPlayer.Character then
local currentHealth = LocalPlayer.Character.Humanoid.Health
local newFrameSize = UDim2.fromScale(currentHealth/100, 1)
local tween = tweenService:Create(greenFrame,info,{Size=newFrameSize})
tween:Play()
if currentHealth > lastHealth then
for i = lastHealth, currentHealth, 1 do
label.Text = math.floor(i) .." / 100"
task.wait(1/(currentHealth-lastHealth))
end
else
for i = lastHealth, currentHealth, -1 do
label.Text = math.floor(i) .." / 100"
task.wait(1/(currentHealth-lastHealth))
end
end
lastHealth = currentHealth
end
end