✓ Accepted answer
Methods
First, on line 3 of your code, you're attempting to use the WaitForChild method on the char variable. Methods can only be called while using a colon : or, a period . while passing the subject as the first argument. A corrected version should look like this:
local player = game.Players.LocalPlayer
local char = player.Character or player.CharacterAdded:wait()
local humanoid = char:WaitForChild("Humanoid")
local health = humanoid.Health
while true do
script.Parent.Parent.Parent.DYING.ImageTransparency = (health / 100)
wait(.01)
end
Events
We don't always have to use events for everything, but it's best to utilize them as best as possible. In this case, there's a very specific event called HealthChanged that's a member of the Humanoid, which will update code whenever the health of the humanoid has been changed. We can use this event to replace your while loop, and this should be your revised code:
local player = game.Players.LocalPlayer
local char = player.Character or player.CharacterAdded:wait()
local humanoid = char:WaitForChild("Humanoid")
humanoid.HealthChanged:connect(function()
local health = humanoid.Health
script.Parent.Parent.Parent.DYING.ImageTransparency = health / humanoid.MaxHealth
end)
Hope that helped, let me know if you have any questions.