PcoWSkbVqDnWTu_dm2ix
Collapse Sidebar

SetPartCollisionGroup

The SetPartCollisionGroup function sets the collision group of the specified part to the group with the specified name.

This function is equivalent to setting the BasePart/CollisionGroupId, although this function is the recommended method of configuring a part’s collision group.

Note that for a part to respect its collision filter setting it must have its BasePart/CanCollide property set to true.

This function will throw a runtime error in the following circumstances:

  • The part parameter is not a BasePart instance.
  • The specified group does not exist.

Parameters

Name Type Default Description

The part being set.

The name of collision group that the part’s collision group is being set to.

Returns

Return Type Summary

No return.


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.