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

How can I get the LocalPlayers health, and show it on a gui?

Asked by 6 years ago

Hey guys!

I wanted to show the health of a player, in a gui. I can't seem to access it.

text = script.Parent

text.Text = game.Players.LocalPlayer.Health

The result is an error. Any ideas?

0
Whats the error? green271 635 — 6y
0
change line 3 to text.Text = game.Players.LocalPlayer.Character.Humanoid.Health greatneil80 2647 — 6y

1 answer

Log in to vote
0
Answered by 6 years ago

The issue is that you are looking for the health inside the player. To easily access the character from the local player quite simple! Just do this

text = script.Parent

text.Text = game.Players.LocalPlayer.Character.Humanoid.Health
0
Is this a local script? Also make sure you didn't make a typo. The humanoid should exist unless there's some script that deletes it. And in that case you can't really get the health on the player. casper123123123 357 — 6y
Ad

Answer this question