Player:LastHitGroup() is always returning 0

I want to recognise if something isn’t a head shot in something I am coding. Player:LastHitGroup() has no documentation on the Wiki and I couldn’t find any sight of it on either.

This is in GM:DoPlayerDeath();
[lua]local LastHitGroup = Player:LastHitGroup();
print( "Hit group: ", LastHitGroup );

if( LastHitGroup != HITGROUP_HEAD ) then
print( “Hi” );

Console prints:

Hit group: 0

No matter where I kill my test subject (a bot) either on the torso or the head the result is always the same.

Any ideas?
Thanks in advance.


I managed to solve it. Will post it for any future people who find LastHitGroup() to be useless:
function GM:ScalePlayerDamage( Player, HitGroup, DamageInfo )
if( HitGroup == HITGROUP_HEAD ) then
Player.ReceivedHeadShot = true;
Player.ReceivedHeadShot = false;

And I then check that boolean in GM:DoPlayerDeath() when I want to see if they died from a head shot or not.

Lock/ignore/whatever this. :slight_smile:

You may want to update the Wiki with your findings. :3

I fixed this in the next update

Thank you very much Garry. :slight_smile:

And I did try and add it to the wiki Unrealomega but the page to Player:LastHitGroup() 404’d so I thought I could at least add it here.