Image doesn't change color

Hi, I have this heart system that lets you know how many hearts you have. Everybody starts with 3, then the number can change if you get hit. And it works, until the last time. The first 3 times the hearts actually change color, from red to black. But when the countdown nears the end, I wanted to make it so that no matter how many hearts the player had left, there would be an image of a red skull, until the player was killed, at which point it would revert to black. And the skull image appears instead of the second heart, but it turns black instead of red and I can’t understand why :frowning:

value:GetPropertyChangedSignal("Value"):Connect(function()
	if value.Value == 3 then
		frame.heart3.ImageColor3 = Color3.fromRGB(191, 38, 2)
		frame.heart2.ImageColor3 = Color3.fromRGB(191, 38, 2)
		frame.heart1.ImageColor3 = Color3.fromRGB(191, 38, 2)
	elseif value.Value == 2 then
		frame.heart3.ImageColor3 = Color3.fromRGB(0, 0, 0)
		frame.heart2.ImageColor3 = Color3.fromRGB(191, 38, 2)
		frame.heart1.ImageColor3 = Color3.fromRGB(191, 38, 2)
	elseif value.Value == 1 then
		frame.heart3.ImageColor3 = Color3.fromRGB(0, 0, 0)
		frame.heart2.ImageColor3 = Color3.fromRGB(0, 0, 0)
		frame.heart1.ImageColor3 = Color3.fromRGB(191, 38, 2)
	elseif value.Value == 0 then
		frame.heart3.ImageColor3 = Color3.fromRGB(0, 0, 0)
		frame.heart2.ImageColor3 = Color3.fromRGB(0, 0, 0)
		frame.heart1.ImageColor3 = Color3.fromRGB(0, 0, 0)
	elseif value.Value == "end" then
		frame.heart3.ImageColor3 = Color3.fromRGB(0, 0, 0)
		frame.heart2.ImageColor3 = Color3.fromRGB(191, 38, 2)
		frame.heart1.ImageColor3 = Color3.fromRGB(0, 0, 0)
		frame.heart2.Image = "http://www.roblox.com/asset/?id=1202170403"
	end
end)

Any help is appreciated!

1 Like

Try changing it manually to see if it works

Is the value a StringValue?

I did and it works, it’s not just a black image, you can change the color

yes, sorry i have to write the number of characters haha

2 Likes

Try using a NumberValue instead of a StringValue.

Because StringValues’s value is a text value like “Hello”, and they’re not digital.

NumberValues’s value is digital.

I’m not sure if this will work but I’m just tryna help lol

2 Likes

i just tried, but it still doesn’t work :sob:

1 Like

Oh

Then I don’t really know what to do. I’m not that good at scripting, sorry:(

2 Likes

try to use this

value.Changed:Connect(function(inner)
	if inner == "3" then
		frame.heart3.ImageColor3 = Color3.fromRGB(191, 38, 2)
		frame.heart2.ImageColor3 = Color3.fromRGB(191, 38, 2)
		frame.heart1.ImageColor3 = Color3.fromRGB(191, 38, 2)
	elseif inner == "2" then
		frame.heart3.ImageColor3 = Color3.fromRGB(0, 0, 0)
		frame.heart2.ImageColor3 = Color3.fromRGB(191, 38, 2)
		frame.heart1.ImageColor3 = Color3.fromRGB(191, 38, 2)
	elseif inner == "1" then
		frame.heart3.ImageColor3 = Color3.fromRGB(0, 0, 0)
		frame.heart2.ImageColor3 = Color3.fromRGB(0, 0, 0)
		frame.heart1.ImageColor3 = Color3.fromRGB(191, 38, 2)
	elseif inner == "0" then
		frame.heart3.ImageColor3 = Color3.fromRGB(0, 0, 0)
		frame.heart2.ImageColor3 = Color3.fromRGB(0, 0, 0)
		frame.heart1.ImageColor3 = Color3.fromRGB(0, 0, 0)
	elseif inner == "end" then
		frame.heart3.ImageColor3 = Color3.fromRGB(0, 0, 0)
		frame.heart2.ImageColor3 = Color3.fromRGB(191, 38, 2)
		frame.heart1.ImageColor3 = Color3.fromRGB(0, 0, 0)
		frame.heart2.Image = "rbxassetid://1202170403"
	end
end)

Try to put image first like this:

value:GetPropertyChangedSignal("Value"):Connect(function()
	if value.Value == 3 then
		frame.heart3.ImageColor3 = Color3.fromRGB(191, 38, 2)
		frame.heart2.ImageColor3 = Color3.fromRGB(191, 38, 2)
		frame.heart1.ImageColor3 = Color3.fromRGB(191, 38, 2)
	elseif value.Value == 2 then
		frame.heart3.ImageColor3 = Color3.fromRGB(0, 0, 0)
		frame.heart2.ImageColor3 = Color3.fromRGB(191, 38, 2)
		frame.heart1.ImageColor3 = Color3.fromRGB(191, 38, 2)
	elseif value.Value == 1 then
		frame.heart3.ImageColor3 = Color3.fromRGB(0, 0, 0)
		frame.heart2.ImageColor3 = Color3.fromRGB(0, 0, 0)
		frame.heart1.ImageColor3 = Color3.fromRGB(191, 38, 2)
	elseif value.Value == 0 then
		frame.heart3.ImageColor3 = Color3.fromRGB(0, 0, 0)
		frame.heart2.ImageColor3 = Color3.fromRGB(0, 0, 0)
		frame.heart1.ImageColor3 = Color3.fromRGB(0, 0, 0)
	elseif value.Value == "end" then
		frame.heart3.ImageColor3 = Color3.fromRGB(0, 0, 0)
		frame.heart2.Image = "http://www.roblox.com/asset/?id=1202170403"
		frame.heart2.ImageColor3 = Color3.fromRGB(191, 38, 2)
                print(frame.heart2.ImageColor3)
		frame.heart1.ImageColor3 = Color3.fromRGB(0, 0, 0)
	end
end)

If it didn’t work tell me what it prints.

1 Like

just told me this
“:arrow_forward: 0.74902, 0.14902, 0.00784314 (x2) - Client - hearts:42”

Oh then I think I know the resson why it is black.
Try to use this:

value:GetPropertyChangedSignal("Value"):Connect(function()
	if value.Value == 3 then
		frame.heart3.ImageColor3 = Color3.new(191/255, 38/255, 2/255)
		frame.heart2.ImageColor3 = Color3.new(191/255, 38/255, 2/255)
		frame.heart1.ImageColor3 = Color3.new(191/255, 38/255, 2/255)
	elseif value.Value == 2 then
		frame.heart3.ImageColor3 = Color3.new(0, 0, 0)
		frame.heart2.ImageColor3 = Color3.new(191/255, 38/255, 2/255)
		frame.heart1.ImageColor3 = Color3.new(191/255, 38/255, 2/255)
	elseif value.Value == 1 then
		frame.heart3.ImageColor3 = Color3.new(0, 0, 0)
		frame.heart2.ImageColor3 = Color3.new(0, 0, 0)
		frame.heart1.ImageColor3 = Color3.new(191/255, 38/255, 2/255)
	elseif value.Value == 0 then
		frame.heart3.ImageColor3 = Color3.new(0, 0, 0)
		frame.heart2.ImageColor3 = Color3.new(0, 0, 0)
		frame.heart1.ImageColor3 = Color3.new(0, 0, 0)
	elseif value.Value == "end" then
		frame.heart3.ImageColor3 = Color3.new(0, 0, 0)
		frame.heart2.Image = "http://www.roblox.com/asset/?id=1202170403"
		frame.heart2.ImageColor3 = Color3.new(191/255, 38/255, 2/255)
		frame.heart1.ImageColor3 = Color3.new(0, 0, 0)
	end
end)

I’m so grateful for the effort you’re putting into this, but unfortunately it remains the same. it always turns black :confused:

it stays the same unfortunately, any other tip?

Try to use this for test and tell me what it prints:

local NumberOfValueChanged = 0
value:GetPropertyChangedSignal("Value"):Connect(function()
	if value.Value == 3 then
		frame.heart3.ImageColor3 = Color3.new(191/255, 38/255, 2/255)
		frame.heart2.ImageColor3 = Color3.new(191/255, 38/255, 2/255)
		frame.heart1.ImageColor3 = Color3.new(191/255, 38/255, 2/255)
	elseif value.Value == 2 then
		frame.heart3.ImageColor3 = Color3.new(0, 0, 0)
		frame.heart2.ImageColor3 = Color3.new(191/255, 38/255, 2/255)
		frame.heart1.ImageColor3 = Color3.new(191/255, 38/255, 2/255)
	elseif value.Value == 1 then
		frame.heart3.ImageColor3 = Color3.new(0, 0, 0)
		frame.heart2.ImageColor3 = Color3.new(0, 0, 0)
		frame.heart1.ImageColor3 = Color3.new(191/255, 38/255, 2/255)
	elseif value.Value == 0 then
		frame.heart3.ImageColor3 = Color3.new(0, 0, 0)
		frame.heart2.ImageColor3 = Color3.new(0, 0, 0)
		frame.heart1.ImageColor3 = Color3.new(0, 0, 0)
               print(NumberOfValueChanged)
	elseif value.Value == "end" then
		frame.heart3.ImageColor3 = Color3.new(0, 0, 0)
		frame.heart2.Image = "http://www.roblox.com/asset/?id=1202170403"
		frame.heart2.ImageColor3 = Color3.new(191/255, 38/255, 2/255)
		frame.heart1.ImageColor3 = Color3.new(0, 0, 0)
               print(NumberOfValueChanged)
	end
        NumberOfValueChanged = NumberOfValueChanged + 1
end)

Okay, then give me the answers to the following questions:

  1. What changes the Value? Please provide the code if possible. (Is the script local or server?);
  2. Provide information about your structure of this UI, show it if possible through Explorer;
  3. Are there any errors in the console when executing the code?
  4. Describe specifically whether any changes occur when you run the code.

make sure youre not changing the image in StarterGui, change it in the players PlayerGui

the problem is not changing the image, it’s the color change

it tells me this
“17:28:41.545 0 - Client - hearts:43”
this one was the second round, i don’t know if this information helps but just in case

Hm, can you show me what frame = to?