Maybe I'm missing something obvious here? For some reason, "Humanoid.Health" isn't updating, and "Humanoid.HealthChanged" only fires when the Humanoid dies. The script is located withing the GUI I'm using (for healthbar) which is inside the Dummies head. Same script works fine for my player HP bar.
local Hum = script.Parent.Parent.Parent.Humanoid local NameVal = script.Parent.NameLab local HPVal = script.Parent.HealthBar.Back.HPLab local Bar = script.Parent.HealthBar.Bar HPVal.Text = Hum.Health .. "/" .. Hum.MaxHealth Hum.Changed:Connect(function() print(Hum.Health) wait(2) end) Hum.HealthChanged:Connect(function(health) HPVal.Text = Hum.Health .. "/" .. Hum.MaxHealth Bar.Size = UDim2.new(Hum.Health/Hum.MaxHealth,0,2,0) end)
The Hum.Health output never changes from 100, until the Humanoid dies.
If you want make a health bar you must writte your script on a LocalScript (ClientScript). Place your script on a client storage, ex: StarterGui (or descendance).
local PlayerService = game:GetService('Players') -- Get the players service. local Player = PlayerService.LocalPlayer -- This is just possible on a LocalScript. local Character = Player.Character or Player.CharacterAdded:wait() -- In case the character model has already been created local PlayerGui = Player:WaitForChild('PlayerGui') -- You can't found PlayerGui with the server, so you can't make this script on a ServerScript (Script) local NameVal = PlayerGui[ name of you screengui ] local HPVal = ... local Bar = ... (it's just a links) Character:WaitForChild('Humanoid'):GetPropertyChangedSignal('Health'):Connect(function() HPVal.Text = Hum.Health .. "/" .. Hum.MaxHealth Bar.Size = UDim2.new(Character.Humanoid.Health / Character.Humanoid.MaxHealth, 0, 2 ,0) end)
EXEMPLE
local PlayerService = game:GetService('Players') local Player = PlayerService.LocalPlayer local Character = Player.Character or Player.CharacterAdded:wait() local PlayerGui = Player:WaitForChild('PlayerGui') local Bar = PlayerGui.ScreenGui.Frame.Frame (Link towards my bar ui) Character:WaitForChild('Humanoid'):GetPropertyChangedSignal('Health'):Connect(function() Bar.Size = UDim2.new(Character.Humanoid.Health / Character.Humanoid.MaxHealth, 0, 1 ,0) end)
Solved your question? Put in title [SOLVED] or accept a answer.