AnimationsClient
NOTE
Roblox model path: Animations\Package\AnimationsClient
Types
initOptions
interface initOptions {AutoLoadAllPlayerTracks: falseAutoRegisterPlayer: trueBootstrapDepsFolder: Folder?TimeToLoadPrints: true}For more info, see Properties.
path
type path = {any} | stringThese are all valid forms of paths to animation tracks you have defined in the AnimationIds module:
local path = "Jump" -- A single key (any type)
local path = {"Dodge", Vector3.xAxis} -- An array path (values of any type)
local path = "Climb.Right" -- A string path separated by "."
Animations:PlayTrack(path)
customRBXAnimationIds
interface customRBXAnimationIds {run: number?walk: number?jump: number?idle: {Animation1: number?,Animation2: number?}?fall: number?swim: number?swimIdle: number?climb: number?}A table of animation ids to replace the default roblox animation ids.
NOTE
The "walk" animation is used for both walking and running on R6 characters.
humanoidRigTypeToCustomRBXAnimationIds
interface humanoidRigTypeToCustomRBXAnimationIds {[Enum.HumanoidRigType.R6]: customRBXAnimationIds?[Enum.HumanoidRigType.R15]: customRBXAnimationIds?}A table mapping a Enum.HumanoidRigType to its supported animation ids that will replace the default roblox animation ids.
Properties
AutoLoadAllPlayerTracks
AnimationsClient.AutoLoadAllPlayerTracks: falseIf set to true, client animation tracks will be loaded each time the client spawns.
AutoRegisterPlayer
AnimationsClient.AutoRegisterPlayer: trueIf set to true, the client will be auto registered with rigType of "Player" each time they spawn.
BootstrapDepsFolder
AnimationsClient.BootstrapDepsFolder: Folder?Set this to the dependencies folder if you have moved it from its original location inside of the root Animations folder.
TimeToLoadPrints
AnimationsClient.TimeToLoadPrints: trueIf set to true, makes helpful prints about the time it takes to pre-load and load animations.
PreloadAsyncProgressed
AnimationsClient.PreloadAsyncProgressed: RBXScriptSignalFires when ContentProvider:PreloadAsync() finishes pre-loading one animation instance.
Animations.PreloadAsyncProgressed:Connect(function(n, total, loadedAnimInstance)
print("ContentProvider:PreloadAsync() finished pre-loading one animation:", n, total, loadedAnimInstance)
end)
Functions
Init
This is a yielding function. When called, it will pause the Lua thread that called the function until a result is ready to be returned, without interrupting other scripts. YieldsInitializes AnimationsClient.
Yields when...
- ...server has not initialized.
- ...animations are being pre-loaded with
ContentProvider:PreloadAsync()(could take a while).
important
Must be called once before any other method.
GetTrackStartSpeed
If set with HasProperties, returns the animation track's StartSpeed.
Rig version - :GetRigTrackStartSpeed()
GetTimeOfMarker
AnimationsClient:GetTimeOfMarker(markerName: string) → number?
This method can yield if the
initialization process that caches all of the marker
times is still going on when this method is called. If
after 3 seconds the initialization process has still not
finished, this method will return nil.
WARNING
This method only works on animations which you give
the MarkerTimes property to.
local attackAnim = Animations:PlayTrack("Attack")
local timeOfHitStart = Animations:GetTimeOfMarker(attackAnim, "HitStart")
print("Time of hit start:", timeOfHitStart)
-- or
local animIdStr = Animations:GetAnimationIdString("Player", "Attack")
local timeOfHitStart = Animations:GetTimeOfMarker(animIdStr, "HitStart")
print("Time of hit start:", timeOfHitStart)
GetAnimationIdString
Returns the animation id string under rigType at path in the AnimationIds module.
local animIdStr = Animations:GetAnimationIdString("Player", "Run")
print(animIdStr) --> "rbxassetid://89327320"
FindFirstRigPlayingTrack
Returns a playing animation track found in
rig.Humanoid.Animator:GetPlayingAnimationTracks()
matching the animation id found at path in the
AnimationIds module or nil.
WARNING
For this to work, rig needs to be registered.
local isBlocking = Animations:FindFirstRigPlayingTrack(rig, "Blocking")
if isBlocking then
warn("We can't hit the enemy, they're blocking!")
end
WaitForRigPlayingTrack
This is a yielding function. When called, it will pause the Lua thread that called the function until a result is ready to be returned, without interrupting other scripts. Yields
Yields until a playing animation track is found in
rig.Humanoid.Animator:GetPlayingAnimationTracks()
matching the animation id found at path in the
AnimationIds module then returns it or returns nil after
timeout seconds if provided.
Especially useful if the animation needs time to replicate from server to client and you want to specify a maximum time to wait until it replicates.
WARNING
For this to work, rig needs to be registered.
local isBlocking = Animations:WaitForRigPlayingTrack(rig, "Blocking", 1)
if isBlocking then
warn("We can't hit the enemy, they're blocking!")
end
GetAppliedProfileName
AnimationsClient:GetAppliedProfileName() → string?Returns the client's currently applied animation profile name or nil.
Rig version - :GetRigAppliedProfileName()
AwaitPreloadAsyncFinished
This is a yielding function. When called, it will pause the Lua thread that called the function until a result is ready to be returned, without interrupting other scripts. YieldsYields until ContentProvider:PreloadAsync() finishes pre-loading all animation instances.
local loadedAnimInstances = Animations:AwaitPreloadAsyncFinished()
print("ContentProvider:PreloadAsync() finished pre-loading all animations:", loadedAnimInstances)
Register
AnimationsClient:Register() → ()Registers the client's character so that methods using animation tracks can be called.
rig version
:RegisterRig()
TIP
Automatically calls rig:SetAttribute("AnimationsRigType", rigType) which is useful for determining rig types.
AwaitRegistered
This is a yielding function. When called, it will pause the Lua thread that called the function until a result is ready to be returned, without interrupting other scripts. YieldsAnimationsClient:AwaitRegistered() → ()Yields until the client gets registered.
Rig version - :AwaitRigRegistered()
IsRegistered
AnimationsClient:IsRegistered() → booleanReturns true if the client is registered.
Rig version - :IsRigRegistered()
ApplyCustomRBXAnimationIds
This is a yielding function. When called, it will pause the Lua thread that called the function until a result is ready to be returned, without interrupting other scripts. YieldsAnimationsClient:ApplyCustomRBXAnimationIds(humanoidRigTypeToCustomRBXAnimationIds: humanoidRigTypeToCustomRBXAnimationIds) → ()Applies the animation ids specified in the humanoidRigTypeToCustomRBXAnimationIds table on the client's character.
Yields when...
- ...the client's character, humanoid, animator, or animate script aren't immediately available.
Animations:ApplyCustomRBXAnimationIds({
[Enum.HumanoidRigType.R15] = {
jump = 656117878,
idle = {
Animation1 = 656117400,
Animation2 = 656118341
}
}
})
rig version
:ApplyRigCustomRBXAnimationIds()
WARNING
Only works for R6/R15 rigs that are local to the client or network-owned by the client and have a client-side "Animate" script in their model.
GetAnimationProfile
AnimationsClient:GetAnimationProfile(animationProfileName: string) → animationProfilehumanoidRigTypeToCustomRBXAnimationIds?Returns the humanoidRigTypeToCustomRBXAnimationIds table from the animation profile module or nil.
INFO
For more info, see animation profiles.
ApplyAnimationProfile
This is a yielding function. When called, it will pause the Lua thread that called the function until a result is ready to be returned, without interrupting other scripts. YieldsAnimationsClient:ApplyAnimationProfile(animationProfileName: string) → ()Applies the animation ids found in the animation profile on the client's character.
Yields when...
- ...the client's character, humanoid, animator, or animate script aren't immediately available.
INFO
For more info, see animation profiles.
rig version
:ApplyRigAnimationProfile()
WARNING
Only works for R6/R15 rigs that are local to the client or network-owned by the client and have a client-side "Animate" script in their model.
AwaitAllTracksLoaded
This is a yielding function. When called, it will pause the Lua thread that called the function until a result is ready to be returned, without interrupting other scripts. YieldsAnimationsClient:AwaitAllTracksLoaded() → ()Yields until the client has been registered and then until all animation tracks have loaded.
Rig version - :AwaitAllRigTracksLoaded()
AwaitTracksLoadedAt
This is a yielding function. When called, it will pause the Lua thread that called the function until a result is ready to be returned, without interrupting other scripts. YieldsYields until the client has been registered and then until all animation tracks have loaded at path.
Rig version - :AwaitRigTracksLoadedAt()
AreAllTracksLoaded
AnimationsClient:AreAllTracksLoaded() → booleanReturns true if the client has had all its animation tracks loaded.
Rig version - :AreAllRigTracksLoaded()
AreTracksLoadedAt
Returns true if the client has had its animation tracks loaded at path.
Rig version - :AreRigTracksLoadedAt()
LoadAllTracks
This is a yielding function. When called, it will pause the Lua thread that called the function until a result is ready to be returned, without interrupting other scripts. YieldsAnimationsClient:LoadAllTracks() → ()Creates animation tracks from all animation ids in AnimationIds for the client.
Yields when...
- ...client's animator is not a descendant of
game.
Rig version - :LoadAllRigTracks()
LoadTracksAt
This is a yielding function. When called, it will pause the Lua thread that called the function until a result is ready to be returned, without interrupting other scripts. YieldsCreates animation tracks from all animation ids in AnimationIds for the client at path.
Yields when...
- ...client's animator is not a descendant of
game.
Rig version - :LoadRigTracksAt()
GetTrack
Returns a client animation track or nil.
Rig version - :GetRigTrack()
PlayTrack
Returns a playing client animation track.
rig version
:PlayRigTrack()
Animations:RegisterRig(rig, "Monster") -- In order to use "Monster" animations (in AnimationIds) on this rig
Animations:LoadAllRigTracks(rig)
Animations:PlayRigTrack(rig, "Run")
StopTrack
Returns a stopped client animation track.
Rig version - :StopRigTrack()
StopPlayingTracks
Returns the stopped client animation tracks.
Rig version - :StopRigPlayingTracks()
GetPlayingTracks
Returns the playing client animation tracks.
Rig version - :GetRigPlayingTracks()
StopTracksOfPriority
AnimationsClient:StopTracksOfPriority(animationPriority: Enum.AnimationPriority,fadeTime: number?) → {AnimationTrack?}Returns the stopped client animation tracks.
Rig version - :StopRigTracksOfPriority()
GetTrackFromAlias
Returns a client animation track or nil.
Rig version - :GetRigTrackFromAlias()
PlayTrackFromAlias
AnimationsClient:PlayTrackFromAlias(alias: any,fadeTime: number?,weight: number?,speed: number?) → AnimationTrackReturns a playing client animation track.
Rig version - :PlayRigTrackFromAlias()
StopTrackFromAlias
Returns a stopped client animation track.
Rig version - :StopRigTrackFromAlias()
SetTrackAlias
Sets an alias to be the equivalent of the path for a client animation track.
Rig version - :SetRigTrackAlias()
TIP
You can use the alias as the last key in the path. Useful for a table of animations. Example:
local AnimationIds = {
Player = {
FistsCombat = {
-- Fists 3 hit combo
Combo = {
[1] = 1234567,
[2] = 1234567,
[3] = 1234567
},
-- Fists heavy attack
HeavyAttack = 1234567
},
SwordCombat = {
-- Sword 3 hit combo
Combo = {
[1] = 1234567,
[2] = 1234567,
[3] = 1234567
},
-- Sword heavy attack
HeavyAttack = 1234567
}
}
}
return AnimationIds
-- After the client's animation tracks are loaded...
local heavyAttackAlias = "HeavyAttack" -- We want this alias in order to call Animations:PlayTrackFromAlias(heavyAttackAlias) regardless what weapon is equipped
local currentEquippedWeapon
local function updateHeavyAttackAliasPath()
local alias = heavyAttackAlias
local path = currentEquippedWeapon .. "Combat"
Animations:SetTrackAlias(alias, path) -- Running this will search first "path.alias" and then search "path" if it didn't find "path.alias"
end
local function equipNewWeapon(weaponName)
currentEquippedWeapon = weaponName
updateHeavyAttackAliasPath()
end
equipNewWeapon("Fists")
Animations:PlayTrackFromAlias(heavyAttackAlias) -- Plays "FistsCombat.HeavyAttack" on the client's character
equipNewWeapon("Sword")
Animations:PlayTrackFromAlias(heavyAttackAlias) -- Plays "SwordCombat.HeavyAttack" on the client's character
RemoveTrackAlias
AnimationsClient:RemoveTrackAlias(alias: any) → ()Removes the alias for a client animation track.
Rig version - :RemoveRigTrackAlias()
AttachWithMotor6d
Attaches the model to the client's character using the motor6dToClone or the first motor6d found as a child of the model in order to animate it.
In either case, the motor6d used must have the following attributes set:
"Part0Name"- the name of thePart0of themotor6dduring the animation."Part1Name"- the name of thePart1of themotor6dduring the animation.
Rig version - :AttachToRigWithMotor6d()
SetRightGripWeldEnabled
AnimationsClient:SetRightGripWeldEnabled(isEnabled: boolean) → ()Enables/disables the RightGrip weld that is automatically added to a character's right hand when a tool is equipped.
Rig version - :SetRigRightGripWeldEnabled()
FindRightGripWeld
Returns the RightGrip weld that is automatically added to a character's right hand when a tool is equipped or nil.
Rig version - :FindRigRightGripWeld()
WaitForRightGripWeld
This is a yielding function. When called, it will pause the Lua thread that called the function until a result is ready to be returned, without interrupting other scripts. YieldsYields until the RightGrip weld that is automatically added to a character's right hand when a tool is equipped is found and then returns it.
Rig version - :WaitForRigRightGripWeld()