Answered by
6 years ago Edited 6 years ago
The following code is to be done in a LocalScript.
First, let's get the LocalPlayer.
1 | Player = game:GetService( "Players" ).LocalPlayer |
To change the Health of the LocalPlayer's Character, we need to get the Character.
1 | Character = Player.CharacterAdded:wait() |
This waits until the character is added, and then returns it. Now, we wait for the Humanoid using WaitForChild()
and then we can change the Health value of the Humanoid.
1 | Character:WaitForChild( "Humanoid" ).Health = (DesiredValue) |
1 | Player = game:GetService( "Players" ).LocalPlayer |
2 | Character = Player.CharacterAdded:wait() |
3 | Character:WaitForChild( "Humanoid" ).Health = (DesiredValue) |
It is important to note that if you want to make the Health greater than 100, you need to change the Humanoid.MaxHealth
and then the Health
, like
1 | Humanoid.MaxHealth = 500 |
So, if the Player's "Power" was a value, you could do:
1 | Player = game:GetService( "Players" ).LocalPlayer |
2 | Character = Player.CharacterAdded:wait() |
3 | Character:WaitForChild( "Humanoid" ).MaxHealth = Power |
4 | Character.Humanoid.Health = Power |
Once again, this is all to be done in a LocalScript.
Try to watch ROBLOX's scripting tutorials and read over the roblox lua reference. Good luck!
If you need any other help or you're confused with something, leave a comment. If I helped you, let me know by accepting my answer.