I am trying to make a safe zone but I don't know how I would set the humanoid's health to 100 every time it got damaged.
✓ ANSWER ACCEPTED
How to add health to a humanoid when touching a brick?
1 answer
✓ Accepted answer
Assuming your "SafeZone" is a single part, you could do this:
ServerScript
local SafeZone = script.Parent
SafeZone.Touched:Connect(function(hit)
if hit and hit.Parent and game:GetService("Players"):GetPlayerFromCharacter(hit.Parent) then
hit.Parent:WaitForChild("Humanoid").Health = 100
end
end)
You can also use the TakeDamage() function of Humanoids by using a negative number, where Line 5 would instead be
hit.Parent:WaitForChild("Humanoid"):TakeDamage(-100)
This discussion is preserved as it was. New answers, comments, and votes are closed.
