imR_otax
(imR_otax)
January 3, 2022, 5:52pm
#1
NPC Health won’t update to Text.
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.
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.
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)
Azul_Cult
(Hannibal Lector)
January 3, 2022, 5:55pm
#3
while true do
wait()
script.Parent.Text = humanoid.Health…"/"…humanoid.MaxHealth
end
1 Like
imR_otax
(imR_otax)
January 3, 2022, 5:56pm
#4
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.
joso555
(joso555)
January 3, 2022, 5:57pm
#6
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
imR_otax
(imR_otax)
January 3, 2022, 5:57pm
#7
I have already tried this before. Didn’t do anything.
Azul_Cult
(Hannibal Lector)
January 3, 2022, 5:58pm
#8
local Humanoid = script.Parent.humanoid
Humanoid.Touched:Connect(function(hit)
script.Parent.Text = Humanoid.Health… “/”… Humanoid.MaxHealth
end)
Try this?
@imR_otax
joso555
(joso555)
January 3, 2022, 5:59pm
#9
The gun is from tooblox, you can use a local script because the gun not really damage the humanoid
imR_otax
(imR_otax)
January 3, 2022, 6:00pm
#10
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.
joso555
(joso555)
January 3, 2022, 6:01pm
#11
no, that gun just do local damage just look just are local scripts inside of it
imR_otax
(imR_otax)
January 3, 2022, 6:03pm
#12
Then do I have to change it to a Server Script?
joso555
(joso555)
January 3, 2022, 6:03pm
#13
but maybe jou just need to use HealthChanged
keith_220
(keith_220)
January 3, 2022, 6:04pm
#14
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
Azul_Cult
(Hannibal Lector)
January 3, 2022, 6:04pm
#15
It’s suppose to be a server script…
cyswip
(cyswip)
January 3, 2022, 6:04pm
#16
its humanoid.Changed:Connect(function()
imR_otax
(imR_otax)
January 3, 2022, 6:04pm
#17
I am using it HealthChanged currently.
joso555
(joso555)
January 3, 2022, 6:04pm
#18
Yeah, because if its local it dont really work
keith_220
(keith_220)
January 3, 2022, 6:05pm
#19
Is the health script a local script? And is the gun script a local or server script?
imR_otax
(imR_otax)
January 3, 2022, 6:06pm
#20
The health text script is a ServerScript and the gun script is a LocalScript