im trying to make a health bar for this mob and it will update upon when the mob is damaged but its not working here is the script
while true do script.Parent.HP.Text = script.Parent.Parent.Parent.Humanoid.Health / script.Parent.Parent.Parent.Humanoid.MaxHealth wait() end
Hello MPforfun,
The reason that your code is not working is because you are dividing the amount of the mob's current health by its max health instead of displaying it. Not only that but you should try to avoid .Parent
a lot of times. Makes the code look really messy. And we do not need a while loop for this scenario. Here is the fixed script:
local mob = script.Parent.Parent.Parent local mobHumanoid = mob:WaitForChild("Humanoid") local UIobject = script.Parent:WaitForChild("HP") mobHumanoid:GetPropertyChangedSignal("Health"):Connect(function() UIobject.Text = mobHumanoid.Health.."/"..mobHumanoid.MaxHealth end)