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
game.Players.PlayerAdded:connect(function(player)
local np = player.Humanoid.Health
script.Parent.Text = np
end)
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
game.Players.PlayerAdded:connect(function(player)
local np = player.Humanoid.Health
script.Parent.Text = np
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:
local player = game.Players.LocalPlayer
repeat wait() until player.Character -- we wait until player has loaded
local character = player.Character
local hum = character:WaitForChild('Humanoid') -- cant call the 'Health', it has to be called in the script, and wait for humanoid to load
script.Parent.Text = 'Current Health: ' .. hum.Health -- we print the humanoid's health, and use double dots to connect the variable with text
This discussion is preserved as it was. New answers, comments, and votes are closed.
1 comment
Thx dude youre a legend