Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

why does my healthchanged:Connect() not work?

Asked by
Kami_Yo 72
5 years ago

The weird thing is it worked before so I don't know why it stopped all of a sudden.

This is my entire script in the Tool of an enemy NPC. It will print out their health, but for some reason, will never run HealthChanged. I have no idea why.

local Character = script.Parent.Parent

local Humanoid = Character:WaitForChild('Enemy')

print("HUMANOID HEALTH: ", Humanoid.Health)

Humanoid.HealthChanged:Connect(function(health)

print("HEALTH CHANGED")

end)
0
It works. It prinks the health out as 50. The HealthChanged is what's causing the issue. I also removed that print statement and HealthChange simply doesn't run. Kami_Yo 72 — 5y
0
question, is the health changing? starmaq 1290 — 5y
0
Yeah, I attack the enemy. This was all set up to make it so the enemy would be stunned and it worked, but all of sudden it's stopped working. I check the enemies health in the game and I can see it lowering and I even kill the enemy, but the HealthChanged never runs. Kami_Yo 72 — 5y
0
Ok I kind of figured it out. One of my Tools' toolScript was a LocalScript and I'm guessing that's what was causing an error. I used another weapon of mine with a regular script for ToolScript and it worked. Kami_Yo 72 — 5y
0
It could be that you are changing the health in a localscript kisty1 111 — 5y

1 answer

Log in to vote
1
Answered by
ben0h555 417 Moderation Voter
5 years ago

If you are detecting those changes on a server script and you are changing the values on a local script then it will not replicate to the server, thats becuase of FE. FE has made games very secure against hackers, though some would argue it wasnt the best way to handle it. FE has broken a lot of classic games and can be difficult to work with for some people, however once you get used to it, it's advantages outweigh the challenges. This is why when you use a server script to do those changes it actually works.

0
Yeah, I simply changed the ToolScript from a LocalScript back into a Script and it worked. Kami_Yo 72 — 5y
Ad

Answer this question