NPC Health won't update to Text

NPC Health won’t update to Text.

  1. What do you want to achieve? Basically, I wanted to create a health bar for my NPC, so whenever it gets damaged (it’s health changes). I only wanted it to be a text, and not an animated bar.

  2. What is the issue? However, it doesn’t ever update. Even after the NPC’s death. It just keeps still; doesn’t change the text at all.

  3. What solutions have you tried so far?
    Messed with the script multiple times. Nothing helped.
    I looked for help on YouTube. Nothing found.
    Searched on DevForum. Didn’t find what I meant.

This is my script:

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

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

How it acts:

1 Like

You spelt ‘Parent’ incorrectly:

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

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

while true do
wait()
script.Parent.Text = humanoid.Health…"/"…humanoid.MaxHealth
end

1 Like

Ah, I see. However, it still does not update the health text. I really don’t know why is that.

I think you should try this instead.

The problem is basically the gun, because the gun just do “false damage” because is just in the client the damage and your script is in the server

I have already tried this before. Didn’t do anything.

local Humanoid = script.Parent.humanoid

Humanoid.Touched:Connect(function(hit)
script.Parent.Text = Humanoid.Health… “/”… Humanoid.MaxHealth
end)

Try this?
@imR_otax

The gun is from tooblox, you can use a local script because the gun not really damage the humanoid

The gun is clearly doing damage to the NPC. I made a ScreenGui TextLabel which updates to humanoid’s health and it worked perfectly fine.

no, that gun just do local damage just look just are local scripts inside of it

Then do I have to change it to a Server Script?

but maybe jou just need to use HealthChanged

What they were trying to say is the gun is doing damage locally, meaning that the player being damaged is not being replicated to the server. Workspace | Roblox Creator Documentation

It’s suppose to be a server script…

its humanoid.Changed:Connect(function()

I am using it HealthChanged currently.

Yeah, because if its local it dont really work

Is the health script a local script? And is the gun script a local or server script?

The health text script is a ServerScript and the gun script is a LocalScript