Entity.TakeDamage
From GMod Wiki
Function | |
Syntax | Entity:TakeDamage( Number amount, Entity attacker, Entity inflictor ) |
Description: | |
Apply damage to the specified entity. | |
Returns: | nil |
In Object: | Entity |
Realm: | |
BBCode Link: | [b][url=http://wiki.garrysmod.com/?title=Entity.TakeDamage]Entity.TakeDamage [img]http://wiki.garrysmod.com/favicon.ico[/img][/url][/b] |
Examples
Description | This example function makes an entity take 15 damage from a specified attacker. |
---|---|
Used on | |
Code | someEntity:TakeDamage( 15, someAttacker, someAttacker:GetActiveWeapon() ) |
Output | N/A |
Additional Notes
- This previously may not have worked on gib/explosive props, but it seems to work fine now.
- The weapon that did the damage should be passed to the third argument (inflictor). Whoever should get credit for the attack should be passed to the second argument (attacker).