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

Stopping health regen? [closed]

Asked by
PredNova 130
8 years ago

I've been making a new health GUI. It works completely fine but how do I remove the script that's in the player to stop their health from regenerating as I'm going to make my own, I have found a previous question like this, But the script that was given doesn't seem to work...

game.Players.LocalPlayer.Character.Health:Destroy()

(LocalScript in StarterGUI)

Thanks :)

Locked by BSIncorporated, Spongocardo, and Redbullusa

This question has been locked to preserve its current state and prevent spam and unwanted comments and answers.

Why was this question closed?

1 answer

Log in to vote
1
Answered by 8 years ago

The character is nil for a few seconds, that is why your script won't work. To solve this, you need to wait until the character is available using the CharacterAdded event's wait method.

game.Players.LocalPlayer.CharacterAdded:wait()
game.Players.LocalPlayer.Character:WaitForChild("Health"):Destroy() --In case the Health script doesn't load with the character.
0
Wow, Something so simple stopped it from working.. Haha. Thanks man :) PredNova 130 — 8y
0
No problem. :) Spongocardo 1991 — 8y
Ad