I’m making a healthbar for my game that turns red when the player’s health is below 25, but i’m having problems.
This is the script:
local bar = script.Parent.Bar
local healthBar = script.Parent.Health
local plr = game.Players.LocalPlayer
local char = plr.Character or plr.CharacterAdded:Wait()
local colorRed = Color3.fromRGB(255, 0, 25)
local colorDefault = Color3.fromRGB(146, 237, 255)
while wait() do
if not char:FindFirstChild("Humanoid") then return end
local health = char.Humanoid.Health
local maxHealth = char.Humanoid.MaxHealth
if char.Humanoid.Health <= 25 then
healthBar.ImageColor3 = colorRed
end
if char.Humanoid.Health > 25 then
healthBar.ImageColor3 = colorDefault
end
healthBar.Size = UDim2.new(bar.Size.X.Scale / maxHealth * health, 0, healthBar.Size.Y.Scale, 0)
end
And i’m getting this error:
ImageColor3 is not a valid member of Frame "Players.playdohcook.PlayerGui.HealthGui.Health"
Anybody know what’s causing this error?