KeyframeSequenceProvider

Show Deprecated
not creatable
service
not replicated

The KeyframeSequenceProvider service provides functions to load and preview KeyframeSequences. It includes a number of functions that are useful when working with Animations.

What is a KeyframeSequence?

A KeyframeSequence stores a series of Poses that encode the hierarchy and motion of an animation. The animation data Roblox uses in the playback of an animation, referenced by the Animation.AnimationId property, can be constructed from a KeyframeSequence. KeyframeSequences are usually created by the Roblox Animation Editor but can be created through other plugins or even manually.

For more information, see the KeyframeSequence page.

What does the KeyframeSequenceProvider do?

The KeyframeSequenceProvider has a number of uses.

  • Download the KeyframeSequence associated with an animation content ID from the Roblox website
  • Generate a temporary id to locally preview an animation
  • Fetch the content IDs of animations owned by a particular user.

Code Samples

Create temporary animation

local KeyframeSequenceProvider = game:GetService("KeyframeSequenceProvider")
local function createPreviewAnimation(keyframeSequence)
local hashId = KeyframeSequenceProvider:RegisterKeyframeSequence(keyframeSequence)
local Animation = Instance.new("Animation")
Animation.AnimationId = hashId
return Animation
end
local keyframeSequence = Instance.new("KeyframeSequence")
local animation = createPreviewAnimation(keyframeSequence)
print(animation)

Summary

Methods

Properties

Methods

RegisterActiveKeyframeSequence

Generates a temporary asset ID from a KeyframeSequence that can be used for localized testing of an animation.

This function performs the same function to KeyframeSequenceProvider:RegisterKeyframeSequence() however this function generates an active:// URL instead of a hash.

The ID generated can be used in an Animation.AnimationId property for testing.

The asset ID generated by this function is temporary and cannot be used outside of Studio. Developers wishing to generate an asset ID that can be used online should upload the KeyframeSequence to Roblox.

Parameters

keyframeSequence: Instance

The KeyframeSequence to be used.


Returns

A temporary asset ID generated for localized animation playback.

Code Samples

Create temporary animation

local KeyframeSequenceProvider = game:GetService("KeyframeSequenceProvider")
local function createPreviewAnimation(keyframeSequence)
local hashId = KeyframeSequenceProvider:RegisterKeyframeSequence(keyframeSequence)
local Animation = Instance.new("Animation")
Animation.AnimationId = hashId
return Animation
end
local keyframeSequence = Instance.new("KeyframeSequence")
local animation = createPreviewAnimation(keyframeSequence)
print(animation)

RegisterKeyframeSequence

Generates a temporary asset ID from a KeyframeSequence that can be used for localized testing of an animation.

This function performs the same function to KeyframeSequenceProvider:RegisterActiveKeyframeSequence() however this function generates a hash instead of an active:// URL.

The ID generated can be used for the Animation.AnimationId property to test animations.

The asset ID generated by this function is temporary and cannot be used outside of Studio. Developers wishing to generate an asset ID that can be used online should upload the KeyframeSequence to Roblox.

Parameters

keyframeSequence: Instance

The KeyframeSequence to be used.


Returns

A temporary asset ID generated for localized animation playback.

Code Samples

KeyframeSequenceProvider:RegisterKeyframeSequence

local KeyframeSequenceProvider = game:GetService("KeyframeSequenceProvider")
local asset = KeyframeSequenceProvider:RegisterKeyframeSequence(workspace.KeyframeSequence)
local animation = Instance.new("Animation")
animation.Name = "TestAnimation"
animation.AnimationId = asset
animation.Parent = workspace

GetAnimations

yields

This function returns an InventoryPages object which can be used to iterate over animations owned by a specific user.

This function has a number of potential uses, such as allowing users to browse and import animations into a custom animation plugin.

Parameters

userId: number

The user ID of the user.


Returns

An InventoryPages of animations.

Code Samples

KeyframeSequenceProvider GetAnimations

local KeyframeSequenceProvider = game:GetService("KeyframeSequenceProvider")
local USER_ID = 0 -- Insert your UserId here
local function extractPages(pagesObject)
local array = {}
while true do
local thisPage = pagesObject:GetCurrentPage()
for _, v in pairs(thisPage) do
table.insert(array, v)
end
if pagesObject.IsFinished then
break
end
pagesObject:AdvanceToNextPageAsync()
end
return array
end
local inventoryPages = KeyframeSequenceProvider:GetAnimations(USER_ID)
local animationIds = extractPages(inventoryPages)
for _, id in pairs(animationIds) do
print(id)
end
print("total: ", #animationIds)

GetKeyframeSequenceAsync

yields

GetKeyframeSequenceAsync returns a KeyframeSequence based on the specified assetId. The assetId must correspond to an animation. The function will yield until the KeyframeSequence is loaded from the website. Because this is a webcall it should wrapped in a pcall.

Parameters

assetId: Content

The content ID of the animation.


Returns

Code Samples

Getting an animation's KeyframeSequence

local KeyframeSequenceProvider = game:GetService("KeyframeSequenceProvider")
local ANIMATION_ID = "rbxassetid://507771019"
-- Get the keyframe sequence for the asset
local keyframeSequence
local success, err = pcall(function()
keyframeSequence = KeyframeSequenceProvider:GetKeyframeSequenceAsync(ANIMATION_ID)
end)
if success then
-- Iterate over each keyframe and print its time value
local keyframeTable = keyframeSequence:GetKeyframes()
for key, value in keyframeTable do
print(`The time of keyframe number {key} is: {value.Time}`)
end
else
print(`Error getting KeyframeSequence: {err}`)
end

Events