When I change the health of the humanoid the healthbar dosen't move at all.
local Humanoid = script.Parent.Parent.Parent.Parent.Parent.Humanoid Humanoid.Changed:Connect(function() script.Parent.Size = UDim2.new((Humanoid.Health/Humanoid.MaxHealth), 0, 1, 0) wait() end)
Everything here was done right. When you were changing the health value, you were changing it from the client and you have filtering enabled. If you go to Test and change it to server side and change the health, it works. :)
Change the script.Parent.Parent.Parent.Parent.Parent.Humanoid
for script.Parent.Parent.Parent.Parent.Parent:WaitForChild("Humanoid")
and you can use :FindFirstChild()
for detect if finded the Humanoid
Here is your fixed script:
wait() if script.Parent.Parent.Parent.Parent.Parent:FindFirstChild("Humanoid") then local Humanoid = script.Parent.Parent.Parent.Parent.Parent:WaitForChild("Humanoid") Humanoid.Changed:Connect(function() script.Parent.Size = UDim2.new((Humanoid.Health/Humanoid.MaxHealth), 0, 1, 0) wait() end) else print("Can not found Humanoid!") end
Remember, change the value with Server. for this use Server Scripts or RemoteEvents...
Hope it helped :D
Wiki pages:
Errors? tell-me on comments.