PcoWSkbVqDnWTu_dm2ix
The Developer Hub is now deprecated and information on this page may no longer be accurate. To see our new and improved documentation, please click here. You can read more about the future of documentation here.
Collapse Sidebar

GetCollisionGroupId

The GetCollisionGroupId function returns the id of the collision group with the specified name.

This function will throw an error if no group with the given name exists.

Parameters

Name Type Default Description

The name of the collision group being retrieved.

Returns

Return Type Summary

int

The id of the retrieved collision group, or nil if no such group exists.


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.