Hello! Someone could help me, I do not understand what is wrong in my textlabel called “Percent”, when life goes down and the conditionals are met the text is not changed and I do not know why this happens, could someone help me?
I would like the text that is above my character “text here” to change to another with the conditions that is programmed
local players = game:GetService("Players")
local PLAYER = game.Players.LocalPlayer
players.PlayerAdded:Connect(function(plr)
plr.CharacterAdded:Connect(function(char)
local gui = script.CustomHealthGui:Clone()
gui.Parent = char.Head
local mainFrame = gui.MainFrame
mainFrame.Username.Text = plr.name
local image = players:GetUserThumbnailAsync(plr.UserId, Enum.ThumbnailType.HeadShot, Enum.ThumbnailSize.Size100x100)
mainFrame.UserImageLabel.Image = image
spawn(function()
while wait() do
mainFrame.HealthLabel.Text = tostring(math.floor(char.Humanoid.Health)).."/"..tostring(math.floor(char.Humanoid.MaxHealth))
mainFrame.HealthBar.Size = UDim2.fromScale((char.Humanoid.Health / char.Humanoid.MaxHealth), 0.4)
while wait() do
mainFrame.HealthLabel.Text = tostring(math.floor(char.Humanoid.Health)).."/"..tostring(math.floor(char.Humanoid.MaxHealth))
mainFrame.HealthBar.Size = UDim2.fromScale((char.Humanoid.Health / char.Humanoid.MaxHealth), 0.4)
if char.Humanoid.Health <= 90 and char.Humanoid.Health >= 80 then
print("SHOW TEXTLABEL")
script.CustomHealthGui.MainFrame.Percent.Text = "WOW HIT HARD!"
elseif char.Humanoid.Health <= 40 then
print("Check2")
script.CustomHealthGui.MainFrame.Percent.Text = "HOLD ON!"
end
end
end
end)
end)
end)