local plr = game.Players.LocalPlayer
local character = plr.Character or plr.CharacterAdded:Wait()
local humanoid = character:WaitForChild("Humanoid")
local bloodOverlay = script.Parent
function update(newHealth)
bloodOverlay.ImageTransparency = newHealth / 100
end)
update()
humanoid.HealthChanged:Connect(update)
This is a script inside of an image label (the blood overlay) but unfortunately does not work and am looking for answers
newhealth is supposed to be number
since you call update without a newhealth, it will probably end with no changing imagetransparency at first (no newHealth
is provided) on update()
to fix it just add Humanoid’s health to it and should be fixed
line 9 code
local Players = game:GetService("Players")
local plr = Players.LocalPlayer
local character = plr.Character or plr.CharacterAdded:Wait()
local humanoid = character:WaitForChild("Humanoid")::Humanoid
local bloodOverlay = script.Parent
local MaxHealth:number = humanoid.MaxHealth
local function update():()
bloodOverlay.ImageTransparency = humanoid.Health/MaxHealth
end
humanoid:GetPropertyChangedSignal("MaxHealth"):Connect(function():()
MaxHealth = humanoid.MaxHealth
end)
humanoid.HealthChanged:Connect(update)
update()
1 Like