I’m trying to make an image label change its image 3 color when the player is at or below a certain amount of health, but for some reason the image 3 color does not change even when I have this script. I’m not sure if I called humanoid health correctly or not, since nothing happens.
local player = game.Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local humanoid = character:WaitForChild("Humanoid")
local Condition = script.Parent:FindFirstChild("ConditionDisplayer")
if humanoid.Health <= 25 then
Condition.ImageColor3 = Color3.fromRGB(255, 0, 0)
end


I want that green backdrop to change to red when the player is at or below 25 health.
i dont think you can change image colors unless its the background but idk cause i dont use uis
Right now, you’ve coded this to only check right when the player spawns. You haven’t added any conditions to do this when the health changes. In order for this to change, you’re going to have to add something to detect when the health changes constantly.
local player = game.Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local humanoid = character:WaitForChild("Humanoid")
local Condition = script.Parent:FindFirstChild("ConditionDisplayer")
humanoid.HealthChanged:Connect(function()
if humanoid.Health <= 25 then
Condition.ImageColor3 = Color3.fromRGB(255, 0, 0)
end
end)
1 Like
humanoid:GetPropertyChangedSignal("Health"):Connect(function()
if humanoid.Health <= 25 then
Condition.ImageColor3 = Color3.fromRGB(255,0,0)
end
end)
edit: dammit @alphadoggy111 beat me to it
Another way you can do it is
while true do
if humanoid.Health <= 25 then
Condition.ImageColor3 = Color3.fromRGB(255,0,0)
end
wait(0.1)
end
3 Likes