Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How do I health a certain player? [HELP!]

I tried:

game.Workspace.PlayerNameHere.maxhealth=100


but i don't think thats the correct line. i already made a thread about this but none of the lines that were given to me worked ):

does it need a function?

8 comments

0

Just as @AlphaGamer150 said you need to access the Humanoid of the player, also Lua is case sensitive..

0

Also... how do I health??? WHAT. Learn English.

0

Maybe the studios script service is broken..? Still not working D:

0

How do you know its not working?

0

Is there an error?

0

An error would tell us what your doing wrong.

0

@ScriptingHelper1038 Here, go gain some braincells... https://www.robloxdev.com/learn-roblox/coding-scripts

0

Can someone please close this question? She probably took the answer and doesn't want to accept our answers D:

2 answers

You are referencing the player modal, to change the max health of a player, you need to reference the humanoid, like this: game.Workspace.PlayerNameHere.Humanoid.MaxHealth = 100

To give a player a certain amount of health when they join:

game.Players:PlayerAdded:Connect(function(player)
	player.Character:WaitForChild("Humanoid").MaxHealth = Number
end)

4 comments

0

This is not working either, do I have to put into ServerScriptService?

0

Basically, I'm trying to health ONE CERTAIN player in a server when he/she joins a server. The automated health is 100 but I'd like to change that to 150 max health. I don't know why this is hard for me to do ):

0

Make sure its in a normal script not a local one

0

I have updated my answer to include a basic function in witch it can be accomplished.

try this

script:

game.Players.PlayerAdded:Connect(function(p)
 p.CharacterAdded:Connect(function(c)
  if p.Name == "YOURNAME" then
	c.Humanoid.MaxHealth = 150
end
end)
end)  

5 comments

0

That is very over complicated.

0

Not really, its quite basic to me.

0

Wait something like CharacterAdded exists... you learn something new everyday.

0

Lol.

0

I'm done with this idiot.

This discussion is preserved as it was. New answers, comments, and votes are closed.