PcoWSkbVqDnWTu_dm2ix
We use cookies on this site to enhance your user experience
Collapse Sidebar

TakeDamage

This function subtracts damage from the Humanoid/Health of the Humanoid if it is not protected by a ForceField.

How do ForceFields protect against TakeDamage

A Humanoid is considered protected by a ForceField if a ForceField meets one of the following criteria:

  • The ForceField shares the same Instance/Parent as the Humanoid
  • The ForceField is parented to the Humanoid/RootPart of the Humanoid
  • The ForceField is parented to an ancestor of the Humanoid other than the Workspace

This function accepts negative values for the amount parameter, this results in an increase in Humanoid/Health. However this will only have an effect if no ForceField is present.

To do damage to a Humanoid irrespective of any ForceField|ForceFields present, set Humanoid/Health directly.

For more information on how ForceField|ForceFields protect Humanoid|Humanoids see the ForceField page

Parameters

Name Type Default Description

The damage, or amount to be deduced from the Humanoid/Health

Returns

Return Type Summary

Code Samples


Humanoid:TakeDamage

This code, put in a LocalScript, would make the local player take 99 damage only if a ForceField wasn’t present.

game.Players.LocalPlayer.Character.Humanoid:TakeDamage(99)