# ValueCurve

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)
- Memory category: Instances
- HTML page: https://rapi.sleaze.dev/classes/ValueCurve/
- Roblox documentation: https://create.roblox.com/docs/reference/engine/classes/ValueCurve

A sorted list of time-value pairs that define a curve. Used to animate any type of value.

## Properties

### Length

```luau
ValueCurve.Length: number = 0
```

- Tags: Read only, Read capabilities: Basic, Save only

Number of keys in the value curve.

### ValuesAndTimes

```luau
ValueCurve.ValuesAndTimes: string = "\u0002"
```

- Tags: Hidden, Not scriptable, Read capabilities: Basic

### ValueType

```luau
ValueCurve.ValueType: string = nil
```

- Tags: Read only, Read capabilities: Basic, Save only

Read-only value indicating the type held in this curve.

## Methods

### GetKeyAtIndex

```luau
ValueCurve:GetKeyAtIndex(index: number): ValueCurveKey
```

- Tags: Capabilities: Basic

Returns a copy of a key at a given index.

Parameters:

- `index`: The index in the existing set of keys held by this [`ValueCurve`](https://rapi.sleaze.dev/classes/ValueCurve.md).

Returns: A copy of the [`ValueCurveKey`](https://rapi.sleaze.dev/index/types/ValueCurveKey.md) stored at the given `index`.

### GetKeyIndicesAtTime

```luau
ValueCurve:GetKeyIndicesAtTime(time: number): { any }
```

- Tags: Capabilities: Basic

Returns the index of the last and first key of a period of time.

Parameters:

- `time`: A time during the animation. Inputs will be clamped between `0` and the time of the last key held by this [`ValueCurve`](https://rapi.sleaze.dev/classes/ValueCurve.md).

Returns: An array of two indices bracketing `time`: the index of the last key at or before `time`, and the index of the first key at or after `time`.

### GetKeys

```luau
ValueCurve:GetKeys(): { any }
```

- Tags: Capabilities: Basic

Returns a copy of all the keys in the ValueCurve as a Luau array of `ValueCurveKeys`.

Returns: Array of `ValueCurveKeys`.

### GetValueAtTime

```luau
ValueCurve:GetValueAtTime(time: number): any?
```

- Tags: Capabilities: Basic

Samples the value curve at a given time passed as argument.

Parameters:

- `time`: Time at which to sample the curve.

Returns: Value of the curve at the requested `time`.

### InsertKey

```luau
ValueCurve:InsertKey(key: ValueCurveKey): { any }
```

- Tags: Capabilities: Basic

Adds the key passed as an argument to this curve. If a key at the same time is found, it will be replaced.

Parameters:

- `key`: [`ValueCurveKey`](https://rapi.sleaze.dev/index/types/ValueCurveKey.md) to insert.

Returns: (see description)

### InsertKeyValue

```luau
ValueCurve:InsertKeyValue(time: number, value: any, keyInterpolationMode: Enum.KeyInterpolationMode? = Enum.KeyInterpolationMode.Constant): { any }
```

- Tags: Capabilities: Basic

Creates a key for the given value and inserts it at the given time. If a key at the same time is found, it will be replaced.

Parameters:

- `time`: Time at which to insert the new [`ValueCurveKey`](https://rapi.sleaze.dev/index/types/ValueCurveKey.md). - type: number
- `value`: Value of the inserted [`ValueCurveKey`](https://rapi.sleaze.dev/index/types/ValueCurveKey.md). - type: any

Returns: (see description)

### RemoveKeyAtIndex

```luau
ValueCurve:RemoveKeyAtIndex(startingIndex: number, count: number? = 1): number
```

- Tags: Capabilities: Basic

Removes a given number of keys starting from a given index.

Parameters:

- `startingIndex`: Starting index from which to remove keys.
- `count`: Number of keys to remove.

Returns: Number of keys removed.

### SetKeys

```luau
ValueCurve:SetKeys(keys: { any }): number
```

- Tags: Capabilities: Basic

Resets this curve's keys using the [`ValueCurveKey`](https://rapi.sleaze.dev/index/types/ValueCurveKey.md) array passed as an argument.

Parameters:

- `keys`: Array of `ValueCurveKeys`.

Returns: Number of keys inserted.

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