How do I change the humanoid health permanently?

Hi everyone! I am a beginner scripter, so please forgive me if my code is trash lol. I was following a tutorial, and then I kinda winged it, and um now I’m here!
Anyways I am trying to make the humanoid health bigger, like 500-1000 instead of 100. Whenever I test it, my health bar is either really low or only half way, and I don’t know why, and it appears to take the same amount of time to die. Here is my code :smile:

 `game.Players.PlayerAdded:Connect(function(plr)
plr.CharacterAdded:connect(function(Char) 
        if Char:FindFirstChild("Humanoid") then
            Char.Humanoid.MaxHealth = 1000 
            Char.Health = Char.Humanoid.MaxHealth
        end
    end)
end) `

Thank you for helping me :smile:

You are attempting to changing your character’s Health property (which doesn’t exist) instead of your Humanoid’s health value.

Also an important tip for the future: Make sure that you’re waiting for the Humanoid before doing anything with it. In your code you’re only changing the health if the Humanoid exists instantly as soon as the character loaded. If your Humanoid isn’t loaded into your Character yet when you call that statement then it’s never going to do anything.

Example:

local Character = Player.Character
local Humanoid = Character:WaitForChild("Humanoid") -- Yields until the humanoid exists or the cooldown is over (5s)

if Humanoid then -- Does your humanoid exist?
    -- Do stuff
end

Hope that helps!

1 Like

Thank you! I’ll try that out and let you know how it goes :smile:

Should be Char.Humanoid.Health I believe.

1 Like

Ohh that would make sense! Thank you, I’ll try that :smile: