Garry's Mod Wiki

Entity:GetNumBodyGroups

  number Entity:GetNumBodyGroups()

Description

Returns the number of Body Groups that the Entity's model contains.

Weapons will return results from their viewmodels.

Returns

1 number
The amount of Body Groups on the Entity's model.

Example

Example usage. Console commands to randomize bodygroups, and print out all bodygroups.

concommand.Add( "print_bodygruops", function( ent ) print("Here's all the bodygroups for " .. ent:GetModel() ) for k = 0, ent:GetNumBodyGroups() do print( ent:GetBodygroupName( k ), " value ", ent:GetBodygroup( k ), " max ", ent:GetBodygroupCount( k ) ) end end ) concommand.Add( "bodygroups_random", function( ent ) print("Randomizing all the bodygroups for " .. ent:GetModel() ) for k = 0, ent:GetNumBodyGroups() do ent:SetBodygroup( k, math.random( 0, ent:GetBodygroupCount( k ) - 1 ) ) end end )