# ChangeHistoryService

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/ChangeHistoryService/
- Roblox documentation: https://create.roblox.com/docs/reference/engine/classes/ChangeHistoryService

**Must** be used by plugins to communicate to Studio how to undo and redo the changes which they make to the experience.

## Methods

### FinishRecording

```luau
ChangeHistoryService:FinishRecording(identifier: string, operation: Enum.FinishRecordingOperation, finalOptions: { [string]: any }?)
```

- Tags: Plugin security

Communicates to Studio that the identified recording is finished and to take the final operation to complete the recording.

Parameters:

- `identifier`: Identifies the recording from the previous call to [`TryBeginRecording()`](https://rapi.sleaze.dev/classes/ChangeHistoryService.md). If the operation is `FinishRecordingOperation.Cancel`, this value is ignored, and the recording is determined by context.
- `operation`: Specifies the operation to take.
- `finalOptions`: Optional table of values to pass to `OnFinishRecording`.

### GetCanRedo

```luau
ChangeHistoryService:GetCanRedo(): ...any
```

- Tags: Plugin security

Returns whether there is an action available to redo and, if so, the name of that action.

Returns: `true` followed by the name of the action that would be redone when a redo is available; otherwise `false`.

### GetCanUndo

```luau
ChangeHistoryService:GetCanUndo(): ...any
```

- Tags: Plugin security

Returns whether there is an action available to undo and, if so, the name of that action.

Returns: `true` followed by the name of the action that would be undone when an undo is available; otherwise `false`.

### IsRecordingInProgress

```luau
ChangeHistoryService:IsRecordingInProgress(identifier: string?): boolean
```

- Tags: Plugin security

Returns whether the plugin currently has a recording in progress, optionally checking for a specific recording identifier.

Parameters:

- `identifier`: Optional identifier of a specific recording to check for. When omitted, the method reports whether *any* recording is in progress for the plugin.

Returns: `true` if a matching recording is in progress; otherwise `false`.

### Redo

```luau
ChangeHistoryService:Redo()
```

- Tags: Plugin security

Re-executes the most recently undone action, advancing forward through the undo/redo history.

### ResetWaypoints

```luau
ChangeHistoryService:ResetWaypoints()
```

- Tags: Plugin security

Clears the undo/redo history by collapsing it into a single base waypoint.

### SetEnabled

```luau
ChangeHistoryService:SetEnabled(state: boolean)
```

- Tags: Plugin security

Sets whether or not the ChangeHistoryService is enabled.

Parameters:

- `state`: Whether to enable (`true`) or disable (`false`) the service.

### SetWaypoint

```luau
ChangeHistoryService:SetWaypoint(name: string)
```

- Tags: Plugin security

Sets a new waypoint which can be used as an undo or redo point.

Parameters:

- `name`: The name to assign to the new waypoint, which appears in the undo/redo history.

### TryBeginRecording

```luau
ChangeHistoryService:TryBeginRecording(name: string, displayName: string?): string?
```

- Tags: Plugin security

Begins tracking changes made to the data model into a recording.

Parameters:

- `name`: Name of the action being performed suitable for logging and coding purposes.
- `displayName`: Name of the action being performed to display to the user.

Returns: A unique string identifier for the recording on success, or `nil` if the recording could not be started.

### Undo

```luau
ChangeHistoryService:Undo()
```

- Tags: Plugin security

Reverts the most recent action, stepping backward through the undo/redo history.

## Events

### OnRecordingFinished

```luau
ChangeHistoryService.OnRecordingFinished: RBXScriptSignal<(name: string, displayName: string?, identifier: string?, operation: Enum.FinishRecordingOperation, finalOptions: { [string]: any }?)>
```

- Tags: Plugin security

Fired when the user completes an action. Parameters come from [`TryBeginRecording()`](https://rapi.sleaze.dev/classes/ChangeHistoryService.md) and [`FinishRecording()`](https://rapi.sleaze.dev/classes/ChangeHistoryService.md).

### OnRecordingStarted

```luau
ChangeHistoryService.OnRecordingStarted: RBXScriptSignal<(name: string, displayName: string?)>
```

- Tags: Plugin security

Fired when the user begins an action. Parameters come from [`TryBeginRecording()`](https://rapi.sleaze.dev/classes/ChangeHistoryService.md).

### OnRedo

```luau
ChangeHistoryService.OnRedo: RBXScriptSignal<(waypoint: string)>
```

- Tags: Plugin security

Fires after an action is redone, reporting the name of the action that was replayed.

### OnUndo

```luau
ChangeHistoryService.OnUndo: RBXScriptSignal<(waypoint: string)>
```

- Tags: Plugin security

Fires after an action is undone, reporting the name of the action that was reverted.

## 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`
