NPC Health won't update to Text

This is the problem. The gun is doing damage ONLY ON THE CLIENT SIDE. This means the server doesn’t know that the NPC died, you would have to use a filtering enabled gun for this to work. If you switch to the server while testing you will see that the NPC is unchanged.

Try adding this one line and debug if the damage is being dealt with in the perspective of the running script:

humanoid  = script.Parent.Parent.Parent.Parent.Parent.Parent.Humanoid

humanoid.Health.Changed:Connect(function()
	print(humanoid.Health)
	script.Parent.Text = humanoid.Health.."/"..humanoid.MaxHealth
end)

If it prints nothing, means health is not being changed.
If it does print, there should be something wrong with other implementations.

It needs to be script.Parent.Text = humanoid.Health…"/"…humanoid.MaxHealth

use HealthChanged to prevent any bug

This doesn’t prevent a bug, this simply just only fires when the health is not increasing from the MaxHealth.

This was already addressed. The problem is because they are not using a filtering enabledgun.

Alright. Let’s say that I have got eiltering enabled on my gun. The text still doesn’t update.

I’m sorry if this is an easy problem, but I am really not into scripting.

You DO have filtering enabled. filtering enabled is not something that is changable. It is no longer optional on roblox. Filtering enabled means: When the client performs an action on an instance the server will not see it UNLESS the client has network ownership over it. The only way to make the gun “Filtering Enabled” would be to use remote events. Try using this gun FE Gun Kit - Edited Version - Roblox and tell me if it works or not. This explains what filtering enabled is better: FilteringEnabled | Roblox Wiki | Fandom

1 Like

I tries using FE Gun Kit, however the text still doesn’t update.

Is the ServerScript a child of the text label?

humanoid = script.Parent.Parent.Parent.Parent.Parent.Parent.Humanoid
Also, are you sure this line is referring to the humanoidd and there is no errors?

  1. Yes it is.
  2. Yes I am totally sure.

Try doing script.Parent.Text = “ABC” in the serverScript on line one and see if that changed the text label to abc. ;

Also when you used the Filtering Enabled gun kit did you put the contents of the folders in their proper places ? https://gyazo.com/918af2fcce56a1ec32352adf4ca537c4

It didn’t change. The text was left blank as it was originally.
And yes I did put them in the correct places.

Can you send a screenshot of the class tree around the textLabel?

humanoid.Changed:Connect(function()
	script.Paernt.Text = humanoid.Health.."/"..humanoid.MaxHealth
end)

You had it as humanoid.Health.Changed, but Health is a property.

Why are you script.parent.parenting the humanoid?, Just define it with game.Workspace.urnpc or script.Parent

But it is still a problem that the text of the text label isn’t changing. The only possible way that

script.Parent.Text = "ABC"

wouldnt change the Text of the TextLabel would be that the script is destroyed OR its parent is no longer the Health TextLabel

The BilboardGui is inside of head and I don’t really want to set it to game.Workspace, I guess it wouldn’t change anything anyways.