I’ve been trying to make a heart icon that changes images depending on the player’s health. Basically, being more broken and broken.
Here’s my script:
local plr = game.Players.LocalPlayer
local character = plr.Character or plr.CharacterAdded:Wait()
local humanoid = character:FindFirstChild("Humanoid")
local image = script.Parent
humanoid.HealthChanged:Connect(function(newvalue)
if newvalue <= 100 then
image.Image = "https://www.roblox.com/library/7917732450/100hpicon"
end
if newvalue <= 75 then
image.Image = "https://www.roblox.com/library/7917733668/75hp"
end
if newvalue <= 50 then
image.Image = "https://www.roblox.com/library/7917734933/50hp"
end
if newvalue <= 35 then
image.Image = "https://www.roblox.com/library/7917736453/35hpicon"
end
if newvalue <= 20 then
image.Image = "https://www.roblox.com/library/7917737527/20hpicon"
end
end)
No matter what I do, the image won’t change when the health is 75, or 50, etc. I’m really clueless as to what I did wrong, so any help would be appreciated. (Yes, the local script is inside the image).
FOR SOLUTION: Make sure to add a > at and newvalue = (>=)