Is there a way to heal a player to max health on join?

I have a script which when the player joins their maxhealth gets multiplied by their LV which if for instance is “50” The player will have a huge health gap gone is there anyway to fix this?

Can you write the script? i don’t really get what you mean “Huge health gap gone”?

Don’t forget about “Health” inside the humanoid! That also has to be multiplied!!

Because what you did, is set the players’ MAX HEALTH to 5000 but they’re health is still 100

so a fix for this would be:

local Humanoid = (path2humanoid)

Humanoid.Health = Humanoid.MaxHealth

humanoid.Health = humanoid.MaxHealth

while wait() do script.Parent.Humanoid.MaxHealth = 100 + (game.Players[script.Parent.Name].leaderstats.LV.Value * 4) end

Whenever a player levels up their maxhealth increases, I want since when they join back there will be a gap due to their level being a level where they can change their maxhealth so it wont be similar to their normal health

You’re only increasing the humanoid’s ‘MaxHealth’ property, you need to set their ‘Health’ property as well.

Thanks this should work I think and to the person above you i turned this into a function

function PlayerHealed(Player)
	local function HealPlayer(Character)
		local humanoid = Character:WaitForChild("Humanoid")
		humanoid.Health = humanoid.MaxHealth
	end
end

Players.PlayerAdded:Connect(PlayerHealed)

If you have a Datastore for the players level and all of that, you already skipped a step you need to do, now what you have to do is this:

game.Players.PlayedAdded:Connect(function(plr)
      local char = plr.Character
      char.Humanoid.Health = char.Humanoid.MaxHealth
end)

I belive thats the answer

Just make sure this code is executed after the humanoid’s ‘MaxHealth’ property has been changed otherwise you’ll encounter a race condition, i.e; humanoid.Health = humanoid.MaxHealth this line of code will execute before while wait() do script.Parent.Humanoid.MaxHealth = 100 + (game.Players[script.Parent.Name].leaderstats.LV.Value * 4) end.

1 Like
script.Parent.Humanoid.MaxHealth = 100 + (game.Players[script.Parent.Name].leaderstats.LV.Value * 4) 
script.Parent.Humanoid.Health = script.Parent.Humanoid.MaxHealth
end

this should fix it
Dunno why the do wait() doesn’t appear

1 Like

Thank you this worked!
I just added it on simply thank you

while wait() do 
	script.Parent.Humanoid.MaxHealth = 100 + (game.Players[script.Parent.Name].leaderstats.LV.Value * 4)
	script.Parent.Humanoid.Health = script.Parent.Humanoid.MaxHealth
end