PcoWSkbVqDnWTu_dm2ix
The Developer Hub is now deprecated and information on this page may no longer be accurate. Instead, you should go to our new and improved documentation. You can also learn more about the future of documentation.
Collapse Sidebar

TakeDamage

This function lowers the Humanoid/Health of the Humanoid by the given amount if it is not protected by a ForceField

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

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

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

No return


Code Samples


Damaging a Humanoid

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