Roblox UtilitiesDevlHub Roblox Documentation

Data type

ValueCurveKey

A time-value pair used with ValueCurve instances.

A time-value pair used with ValueCurve instances.

The Interpolation property dictates the interpolation mode for the segment started by this key and ended by the next key on the curve. Each segment may use a different interpolation mode.

The LeftTangent and RightTangent properties apply to the cubic interpolation mode and define the desired tangent (slope) at the key. Different left and right values can be used to encode discontinuities in slope at the key. Attempting to set a RightTangent value on a key that doesn't use the cubic interpolation mode will result in a runtime error. It is possible to set the LeftTangent property on any key, as it will be used should the preceding segment use cubic interpolation.

Constructors 1#

newReturns a new ValueCurveKey from the given time and value.

new(time: number, value: any, Interpolation: KeyInterpolationMode)#

Creates a new ValueCurveKey at a given time and value. LeftTangent and RightTangent are left uninitialized and, if not initialized, tangent values of '0' will be used when evaluating the curve.

NameTypeDefaultDescription
timenumberTime at which to create the new ValueCurveKey.
valueanyValue of the new ValueCurveKey.
InterpolationKeyInterpolationModeThe interpolation mode for the curve segment starting at this key. Defaults to KeyInterpolationMode.Constant if omitted.

Properties 5#

InterpolationKeyInterpolationModeThe key interpolation mode for the segment started by this ValueCurveKey.
TimenumberThe time position of this ValueCurveKey.
ValueanyThe value of this ValueCurveKey.
RightTangentnumberThe tangent to the right of this ValueCurveKey.
LeftTangentnumberThe tangent to the left of this ValueCurveKey.

Interpolation: KeyInterpolationMode#

Specifies the interpolation mode used for the curve segment that begins at this key and ends at the next key on the ValueCurve. Each segment of the curve can use a different interpolation mode. The default value is KeyInterpolationMode.Constant.

The available modes are:

  • Constant — the segment holds the value of this key until the next key.
  • Linear — the segment linearly interpolates between this key's value and the next key's value.
  • Cubic — the segment uses a cubic Hermite spline defined by this key's RightTangent and the next key's LeftTangent.

Not all value types support Linear or Cubic interpolation. Non-numerical types such as strings, booleans, and enums revert to Constant interpolation regardless of this setting.

Changing this property to a non-cubic mode automatically clears the RightTangent of this key, because only cubic segments use a right tangent.

Time: number#

The time position of this ValueCurveKey along the curve. Defaults to 0. Keys within a ValueCurve are stored sorted by their time values; the time determines where in the animation timeline this key's value applies.

Value: any#

The value stored in this ValueCurveKey. Defaults to nil. Can hold any supported Luau type, including numbers, booleans, strings, Vector2, Vector3, CFrame, UDim, UDim2, NumberRange, NumberSequence, ColorSequence, and enums. All keys on a single ValueCurve must hold values of the same type; attempting to insert a key whose value type differs from existing keys produces an error.

RightTangent: number#

The outgoing tangent (slope) at this key, used when the Interpolation is KeyInterpolationMode.Cubic. Defaults to nil (unset); when unset, an effective tangent of 0 is used during curve evaluation. Attempting to set this property on a key whose interpolation mode is not Cubic throws a runtime error. This property is automatically cleared when Interpolation is changed to a non-cubic mode.

LeftTangent: number#

The incoming tangent (slope) at this key, used when the preceding segment uses KeyInterpolationMode.Cubic interpolation. Defaults to nil (unset); when unset, an effective tangent of 0 is used during curve evaluation. Unlike RightTangent, this property can be set on any key regardless of its own interpolation mode, because it defines the slope at the endpoint of the preceding cubic segment.