Hey i try to make a Gui that says youre current health example : Current Health: 50
Here is my code that is in the Textlabel
1 | game.Players.PlayerAdded:connect( function (player) |
2 | local np = player.Humanoid.Health |
3 | script.Parent.Text = np |
4 | end ) |
Okay so, you cannot have a PlayerAdded inside a localscript, and you cannot call the health value in a variable. Use a localscript, and put the following lines:
1 | local player = game.Players.LocalPlayer |
2 | repeat wait() until player.Character -- we wait until player has loaded |
3 | local character = player.Character |
4 | local hum = character:WaitForChild( 'Humanoid' ) -- cant call the 'Health', it has to be called in the script, and wait for humanoid to load |
5 | script.Parent.Text = 'Current Health: ' .. hum.Health -- we print the humanoid's health, and use double dots to connect the variable with text |