You can write your topic however you want, but you need to answer these questions:
What do you want to achieve? Keep it simple and clear!
error.
What is the issue? Include screenshots / videos if possible!
Not working and no errors popping up on output too.
What solutions have you tried so far? Did you look for solutions on the Developer Hub?
I tried converting it to a function and it still doesn’t work. Am I doing something wrong?
After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!
if humanoid.healthischange then
script.Parent.HPBar.cr=
script.Parent.HPBar.cr =
end
Please do not ask people to write entire scripts or design entire systems for you. If you can’t answer the three questions above, you should probably pick a different category.
Is this just it? Then you can use GetPropertyChangedSignal to detect when the health changes
humanoid:GetPropertyChangedSignal("Health"):Connect(function()
if humanoid.health < humanoid.MaxHealth then
wait(0.25)
script.Parent.HPBar.ImageColor3 = Color3.new(1, 0.309804, 0.309804)
wait(0.5)
script.Parent.HPBar.ImageColor3 = Color3.new(1, 1, 1)
end
end)
If it doesn’t work or you already did that then try adding prints to see if it’s running, I tested this and there’s nothing wrong with your code apparently
local FLASH_COLOR = Color3.new(1, 0.309804, 0.309804)
local ORIGINAL_COLOR = script.Parent.HPBar.ImageColor3
local lastHealth = humanoid.Health
humanoid.HealthChanged:Connect(function(health)
if health < lastHealth then
lastHealth = health
task.wait(0.25)
script.Parent.HPBar.ImageColor3 = FLASH_COLOR
task.wait(0.5)
script.Parent.HPBar.ImageColor3 = ORIGINAL_COLOR
end
lastHealth = health
end)