Hi, akuma67. The answer to the question, "How do I make a script that swaps a decal when player health is low?" is pretty simple.
Since the GUI Design looks amazing :), you want to add a frame on top of it. Make it 0.5 transparency. Then add the following code inside the frame. The code is local script.
local player = game:GetService("Players").LocalPlayer
local character = player.Character or player.CharacterAdded:wait()
local humanoid = character.Humanoid
local playerGui = player.PlayerGui
local healthIndicator = playerGui.Health.HealthIndicator
humanoid.Changed:Connect(function()
if humanoid.Health <= 50 then
healthIndicator.BackgroundColor3 = Color3.new(255/255, 0/255, 0/255)
print ("Low Health!")
else
healthIndicator.BackgroundColor3 = Color3.new(66/255, 138/255, 66/255)
print("You are alive!")
end
end)
If this helped, mark as answered. Have a lovely day of coding!
2 comments
Do you really need to add a Gui on top of it? You could change it's image color to red.. https://puu.sh/A4VBL/f9e2298689.png
Here's how my GUI is set up, with your code I don't think it might work with the way I have it https://i.imgur.com/XQN1Wi7.png