Im trying to make a custom npc health bar but its not working

I tried using a video (shown below) but it didnt work when I tried it in both play and test mode. Pls help.

heres my code

local humanoid = script.Parent.Parent.Parent.Parent:WaitForChild("Humanoid")
local HealthNum = script.Parent.Parent.healthNUM

humanoid.HealthChanged:Connect(function(Damage)
	script.Parent.Size = UDim2.new(Damage / humanoid.MaxHealth, 0,1,0)
end)

local function Number()
	HealthNum.Text = humanoid.Health.."/"..humanoid.MaxHealth
end

Number()
humanoid.HealthChanged:Connect(Number)

Is this a server script or localscript? If it’s a server script and you are changing health on the client it wont work, since server can’t see client changes.

I made it into a local script and it still isnt working

You mean, u want to both player can see health bar status?

im not sure i understand your question sorry

Do you mean that when you launch the game alone, the health bar works, but when you launch it with more players, it doesn’t? I don’t know if I understand what your error is.

no i mean that the health bar doesnt do anything when I damage the NPC. All i was saying before was that I tried to use test mode with 1 player on studio and also tried using the play button in studio, I said this bc play button is a bit unreliable but idk if its important to state or not.