PcoWSkbVqDnWTu_dm2ix
Collapse Sidebar

CollisionGroupId

BasePart

int

The CollisionGroupId property describes the ID number of the part’s collision group. Parts start off in the Default group whose ID is 0. Although this property can be directly changed, it is recommended to instead manipulate the collision group of a part using the name of the group with the /PhysicsService/SetPartCollisionGroup function. You can find the ID of a collision group by using /PhysicsService/GetCollisionGroupId.

This value cannot be negative, and cannot exceed /PhysicsService/GetMaxCollisionGroups. Invalid IDs are clamped.


Code Samples


PhysicsService:GetCollisionGroupId1

This example demonstrates one basic use of collision groups.

The code below attempts to get a group named “Test”, and creates a group this group if it does not already exist. Then, it sets a BasePart|part named Part1’s collision group to “Test”.

If this group is the first collision group you’ve made in your game, it’s Id will be 1.

Parts in the same collision group will interact with other collision groups and with each other a predetermined way. Collision groups can be collidable or not collidable - as set by PhysicsService/CollisionGroupSetCollidable and checked by PhysicsService/CollisionGroupsAreCollidable.