Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

NPC BillboardGui Health bar won't move when health gets changed?

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)

1 comment

0

ServerScript inside a billboardgui insides 3 frames

2 answers

✓ Accepted answer

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. :)

2 comments

1

thanks mr vex

1

yw mr blox

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:

FindFirstChild

WaitForChild

Errors? tell-me on comments.

1 comment

0

not working either, no errors

This discussion is preserved as it was. New answers, comments, and votes are closed.