# PhysicsService

Roblox Engine API class from Roblox Studio 0.744.0.7441077 (version-7aaa6838d36c4448).

- Inherits from, nearest first: [Instance](https://rapi.sleaze.dev/classes/Instance.md), [Object](https://rapi.sleaze.dev/classes/Object.md)
- Tags: Not creatable, Service
- Memory category: Instances
- HTML page: https://rapi.sleaze.dev/classes/PhysicsService/
- Roblox documentation: https://create.roblox.com/docs/reference/engine/classes/PhysicsService

Service that provides methods for creating and managing collision groups, which control whether sets of `BaseParts` collide with each other.

## Methods

### CollisionGroupsAreCollidable

```luau
PhysicsService:CollisionGroupsAreCollidable(name1: string, name2: string): boolean
```

- Tags: Capabilities: Physics, Simulation access

Returns whether the two groups will collide.

Parameters:

- `name1`: The name of the first collision group.
- `name2`: The name of the second collision group.

Returns: `true` if the two groups are set to collide, `false` otherwise. Also returns `true` if either group is unregistered.

### CollisionGroupSetCollidable

```luau
PhysicsService:CollisionGroupSetCollidable(name1: string, name2: string, collidable: boolean)
```

- Tags: Capabilities: Physics, Simulation access

Sets the collision status between two groups.

Parameters:

- `name1`: The name of the first collision group.
- `name2`: The name of the second collision group.
- `collidable`: Whether the two groups should collide with each other.

### GetMaxCollisionGroups

```luau
PhysicsService:GetMaxCollisionGroups(): number
```

- Tags: Capabilities: Physics, Simulation access

Returns the maximum number of collision groups.

Returns: The maximum number of collision groups supported, currently 32.

### GetRegisteredCollisionGroups

```luau
PhysicsService:GetRegisteredCollisionGroups(): { any }
```

- Tags: Capabilities: Physics, Simulation access

Returns a table with info on all of the place's collision groups.

Returns: An array of tables, each containing `name` (string) and `mask` (integer) fields for a registered collision group.

### IkSolve

```luau
PhysicsService:IkSolve(part: BasePart, target: CFrame, translateStiffness: number, rotateStiffness: number)
```

- Tags: Roblox script security, Capabilities: Physics

### IsCollisionGroupRegistered

```luau
PhysicsService:IsCollisionGroupRegistered(name: string): boolean
```

- Tags: Capabilities: Physics, Simulation access

Checks if a collision group is registered.

Parameters:

- `name`: The name of the collision group to check.

Returns: `true` if a collision group with the given name is registered, `false` otherwise.

### LocalIkSolve

```luau
PhysicsService:LocalIkSolve(part: BasePart, target: CFrame, translateStiffness: number, rotateStiffness: number)
```

- Tags: Local user security, Capabilities: Physics

### RegisterCollisionGroup

```luau
PhysicsService:RegisterCollisionGroup(name: string)
```

- Tags: Capabilities: Physics, Simulation access

Registers a new collision group with the given name.

Parameters:

- `name`: The name of the collision group to register.

### RenameCollisionGroup

```luau
PhysicsService:RenameCollisionGroup(from: string, to: string)
```

- Tags: Capabilities: Physics, Simulation access

Renames specified collision group.

Parameters:

- `from`: The current name of the collision group to rename.
- `to`: The new name for the collision group.

### UnregisterCollisionGroup

```luau
PhysicsService:UnregisterCollisionGroup(name: string)
```

- Tags: Capabilities: Physics, Simulation access

Unregisters the collision group for the given name.

Parameters:

- `name`: The name of the collision group to unregister.

### CollisionGroupContainsPart

```luau
PhysicsService:CollisionGroupContainsPart(name: string, part: BasePart): boolean
```

- Tags: Deprecated, Capabilities: Physics

**Deprecated:** This method has been deprecated. It's recommended that you query a part's collision group through its `CollisionGroup` property.

Returns whether the part is in the collision group.

Parameters:

- `name`: The name of the collision group to check.
- `part`: The [`BasePart`](https://rapi.sleaze.dev/classes/BasePart.md) to check for membership in the collision group.

Returns: `true` if the part belongs to the specified collision group, `false` otherwise.

### CreateCollisionGroup

```luau
PhysicsService:CreateCollisionGroup(name: string): number
```

- Tags: Deprecated, Capabilities: Physics
- Use instead: [`PhysicsService.RegisterCollisionGroup`](https://rapi.sleaze.dev/classes/PhysicsService.md)

**Deprecated:** This method has been superseded by [`RegisterCollisionGroup()`](https://rapi.sleaze.dev/classes/PhysicsService.md) which should be used for all new work.

Creates a new collision group with the given name, and returns the ID of the created group.

Parameters:

- `name`: The name of the new collision group to create.

Returns: The integer ID assigned to the newly created collision group.

### GetCollisionGroupId

```luau
PhysicsService:GetCollisionGroupId(name: string): number
```

- Tags: Deprecated, Capabilities: Physics

**Deprecated:** This method has been deprecated. It's recommended that you query collision groups by **name** through a part's `CollisionGroup` property.

Returns the ID of the collision group with the specified name.

Parameters:

- `name`: The name of the collision group being retrieved.

Returns: The ID of the retrieved collision group, or `nil` if no such group exists.

### GetCollisionGroupName

```luau
PhysicsService:GetCollisionGroupName(name: number): string
```

- Tags: Deprecated, Capabilities: Physics

**Deprecated:** This method has been deprecated. It's recommended that you query collision groups by **name** through a part's `CollisionGroup` property.

Returns the name of the group with the corresponding ID.

Parameters:

- `name`: The integer ID of the collision group to look up.

Returns: The name of the collision group with the given ID, or an empty string if the ID has not been assigned to a group.

### GetCollisionGroups

```luau
PhysicsService:GetCollisionGroups(): { any }
```

- Tags: Deprecated, Capabilities: Physics
- Use instead: [`PhysicsService.GetRegisteredCollisionGroups`](https://rapi.sleaze.dev/classes/PhysicsService.md)

**Deprecated:** This method has been superseded by [`GetRegisteredCollisionGroups()`](https://rapi.sleaze.dev/classes/PhysicsService.md) which should be used for all new work.

Returns a table with info on all of the place's collision groups.

Returns: An array of tables, each containing `name` (string), `id` (integer), and `mask` (integer) fields for a registered collision group.

### RemoveCollisionGroup

```luau
PhysicsService:RemoveCollisionGroup(name: string)
```

- Tags: Deprecated, Capabilities: Physics
- Use instead: [`PhysicsService.UnregisterCollisionGroup`](https://rapi.sleaze.dev/classes/PhysicsService.md)

**Deprecated:** This method has been superseded by [`UnregisterCollisionGroup()`](https://rapi.sleaze.dev/classes/PhysicsService.md) which should be used for all new work.

Removes the collision group with the given name.

Parameters:

- `name`: The name of the collision group to remove.

### SetPartCollisionGroup

```luau
PhysicsService:SetPartCollisionGroup(part: BasePart, name: string)
```

- Tags: Deprecated, Capabilities: Physics

**Deprecated:** This method has been deprecated. It's recommended that you set a part's collision group by **name** through its `CollisionGroup` property.

Sets the collision group of a part.

Parameters:

- `part`: The part being set.
- `name`: The name of collision group that the part's collision group is being set to.

## Events

### CollisionGroupCollidableChanged

```luau
PhysicsService.CollisionGroupCollidableChanged: RBXScriptSignal<(collisionGroupIndex1: number, collisionGroupIndex2: number)>
```

- Tags: Hidden, Roblox engine security, Capabilities: Physics

## Inherited members

- From [Instance](https://rapi.sleaze.dev/classes/Instance.md): `Archivable`, `archivable`, `Attributes`, `AttributesReplicate`, `AttributesSerialize`, `HistoryId`, `Name`, `Parent`, `PredictionMode`, `PropertyStatusStudio`, `RobloxLocked`, `SerializedOverrides`, `SourceAssetId`, `Tags`, `UniqueId`, `numExpectedDirectChildren`, `DataCost`, `Capabilities`, `DefinesCapabilities`, `IsInSandbox`, `Sandboxed`, `AddTag`, `ClearAllChildren`, `Clone`, `Destroy`, `FindFirstAncestor`, `FindFirstAncestorOfClass`, `FindFirstAncestorWhichIsA`, `FindFirstChild`, `FindFirstChildOfClass`, `FindFirstChildWhichIsA`, `FindFirstDescendant`, `GetActor`, `GetAttribute`, `GetAttributeChangedSignal`, `GetAttributes`, `GetChildren`, `GetDebugId`, `GetDescendants`, `GetFullName`, `GetStyled`, `GetStyledPropertyChangedSignal`, `GetTags`, `HasTag`, `IsAncestorOf`, `IsDescendantOf`, `IsPropertyModified`, `QueryDescendants`, `RemoveTag`, `ResetPropertyToDefault`, `SetAttribute`, `WaitForChild`, `Remove`, `children`, `clone`, `destroy`, `findFirstChild`, `getChildren`, `isDescendantOf`, `remove`, `AncestryChanged`, `AttributeChanged`, `ChildAdded`, `ChildRemoved`, `DescendantAdded`, `DescendantRemoving`, `Destroying`, `StyledPropertiesChanged`, `childAdded`
- From [Object](https://rapi.sleaze.dev/classes/Object.md): `ClassName`, `className`, `GetPropertyChangedSignal`, `IsA`, `isA`, `Changed`
