Setting Players to Full Health

Setting Players to Full Health

Jun 14 2019, 4:46 PM PST

You want a part to heal a player when they touch it.

Set the Humanoid’s Health property to its Humanoid/MaxHealth|MaxHealth property.

local healPart = Workspace.HealPart
function onTouched(otherPart)
	local human = hit.Parent:FindFirstChild("Humanoid")
	if human then
		human.Health = human.MaxHealth

We connect the Humanoid/Touched|Touched event to a part in the Workspace called “HealPart”. We then safely index a Humanoid from the parent of the object which touched the healing part. If this Humanoid exists, then we set its Humanoid/Health|Health to the total amount of health it can have, which is contained within its Humanoid/MaxHealth|MaxHealth property.

  • powerup
  • health
  • humanoid
  • script