local player = game.Players.LocalPlayer.Humanoid
if player then
player.Humanoid.Health = 10
end
I've tried to get this to work, but it just won't. Anyone have any advice?
local player = game.Players.LocalPlayer.Humanoid
if player then
player.Humanoid.Health = 10
end
I've tried to get this to work, but it just won't. Anyone have any advice?
The player does not have a humanoid; for this reason you must instead use the following:
local player = game.Players.LocalPlayer.Character.Humanoid
local player = game.Players.LocalPlayer.Character:findFirstChild("Humanoid")
if player then
player.Health = 10
else
end
Should I change it to:
player.Humanoid.MaxHealth = 10
end
?
local player = game.Players.LocalPlayer.Character:findFirstChild("Humanoid")
if player then
player.Health = 10
end
The one below will also work you just have to put it into a LocalScript and into StarterGui.
Put it in a LocalScript in StarterGui. LocalScripts can only go in players backpack or PlayerGui (PlayerGui = StarterGui) Scripts can't run LocalPlayer, only LocalScripts.
local player = game.Players.LocalPlayer.Humanoid
if player ~= nil then -- ~= means it's the opposite. So if it were to say = nil, that means if it is nil it will work, if it is ~= and Humanoid is nil, it won't work.
player.Humanoid.Health = 10
end
This discussion is preserved as it was. New answers, comments, and votes are closed.
3 comments
Did not work.
Oh. That didn't work either. Should I do. player.MaxHealth = 10?
Make sure the script is in a local area, StarterGui for example, also make sure that you put a wait at the beginning incase the character has not fully loaded yet.