My goal is to fix the health bar. The code isn’t wrong I believe but the photos aren’t working. Is it just a ROBLOX issue?
The issue is: I cannot see image change when taking damage
And yes. I did try fixing it even using Roblox assistant, nothing works. For example: It’s a break in fangame so your image changes depending on health.
Tried solutions yet didn’t work, dunno.
Heres the code and where the script is placed:
local player = game.Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local humanoid = character:WaitForChild("Humanoid")
local healthChangedConnection
local function changeImage()
local health = humanoid.Health
local image = script.Parent
if health >= 150 then
image.Image = "rbxassetid://16354951180"
elseif health >= 100 then
image.Image = "rbxassetid://16354904709"
elseif health >= 50 then
image.Image = "rbxassetid://16354908663"
else
image.Image = "rbxassetid://16354956278"
end
end
-
healthChangedConnection = humanoid.HealthChanged:Connect(changeImage)
Oh and one more thing, I’m unsure how to make effects and the text say like -10 depending on health taken so if anyone could help me with that, would also need help. Thanks!
Also my first ever post so its kinda bad. never noticed I was a member her but took awhile I guess so w [it took like 2 years ]
And yes, I honestly don’t think capitalization matters here much but yeah uhm
I really need help with this.
Also I think 2 years ago I had the same issue with changing decal ID, my solution was literally just make multiple imageframes and turning their visibility on/off when I want to use the specific image. (Rather than changing the id)
in your code you have local image = script.Parent… the image variable references the Healthbar GUI instead of the ImageLabel that you want, because that’s what your local script is parented to. the GUI itself doesn’t have any image value so it doesn’t work. to reference the actual image, just change the image variable to local image = script.Parent.ImageLabel.
local player = game.Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local humanoid = character:WaitForChild("Humanoid")
local healthChangedConnection
local function changeImage()
local health = humanoid.Health
local image = script.Parent.ImageLabel
if health >= 150 then
image.Image = "rbxassetid://16354951126"
elseif health >= 100 then
image.Image = "rbxassetid://16354904673"
elseif health >= 50 then
image.Image = "rbxassetid://16354908590"
else
image.Image = "rbxassetid://16354956235"
end
end
healthChangedConnection = humanoid.HealthChanged:Connect(changeImage)
New script. Images show when taking damage but images don’t change. ???