Health Bar similar to Break In 2 doesn't work properly? Help?

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:
Screenshot 2024-04-20 at 9.53.35 PM




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. :smiley: never noticed I was a member her but took awhile I guess so w [it took like 2 years :sob:]

And yes, I honestly don’t think capitalization matters here much but yeah uhm
I really need help with this.

are you trying to change the image of a screengui? you need to make an image label inside the screengui, then change the image of that

edit: looked at the post again, ignore my original comment. you need to set image to script.parent.ImageLabel

Use humanoid.HealthChanged to make the text say -10 depending on health taken.

Also if you uploaded the images recently, it has to pass moderation first.

Check this post if your image was not recently made: Can't seem to load image - #2 by rogchamp

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)

I would recommend putting a print statement inside the function first just to see if it is actually running.

the images work, will attempt it

it’s under the health bar and not in image label, should i put it in there? also wdym by script.parent.ImageLabel exactly?

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.