### Animation Configuration with HasProperties (Lua) Source: https://context7.com/wrello/animations/llms.txt This example shows how to use the 'HasProperties' utility within the AnimationIds module to define animations with specific properties such as priority, looping behavior, and start speed. It also demonstrates how to access and apply these configured properties when playing animations. ```lua -- Inside ReplicatedStorage.Animations.Deps.AnimationIds local AnimationIdsUtil = require(script.Parent.Parent.Package.Util.AnimationIdsUtil) local HasProperties = AnimationIdsUtil.HasProperties local AnimationIds = { Player = { -- Simple animation without properties Jump = 656117878, -- Animation with priority set Dodge = HasProperties(7891234, { Priority = Enum.AnimationPriority.Action, Looped = false }), Sword = { -- Multiple animations with shared properties AttackCombo = HasProperties({ [1] = 3456781, [2] = 3456782, [3] = 3456783 }, { Priority = Enum.AnimationPriority.Action, MarkerTimes = true, -- Enable marker time support StartSpeed = 1.2 -- Auto-set playback speed }), -- Special attack with custom start speed SpecialAttack = HasProperties(4567890, { Priority = Enum.AnimationPriority.Action4, Looped = false, StartSpeed = 0.8, MarkerTimes = true }) } } } return AnimationIds -- Using the configured animations in code -- In a ServerScript local Animations = require(game.ReplicatedStorage.Animations.Package.AnimationsServer) Animations:Init({AutoLoadAllPlayerTracks = true}) game.Players.PlayerAdded:Connect(function(player) player.CharacterAdded:Connect(function() Animations:AwaitAllTracksLoaded(player) -- Get the configured start speed local startSpeed = Animations:GetTrackStartSpeed(player, "Sword.SpecialAttack") print("Special attack start speed:", startSpeed) -- 0.8 -- Play animation (StartSpeed is automatically applied) Animations:PlayTrack(player, "Sword.SpecialAttack") end) end) ``` -------------------------------- ### Using Reusable Animation Profiles (Lua) Source: https://context7.com/wrello/animations/llms.txt This example shows how to create and apply reusable animation profiles for consistent character customization across different situations. It defines a 'NinjaProfile' in a ModuleScript and applies it in a server script using the AnimationsServer module. It also demonstrates how to get the current profile name and switch profiles dynamically. ```lua -- In ReplicatedStorage.Animations.Deps.NinjaProfile (ModuleScript) local NinjaProfile = { [Enum.HumanoidRigType.R15] = { jump = 656117878, run = 616163682, idle = { Animation1 = 656117400, Animation2 = 656118341 } } } return NinjaProfile -- In a ServerScript local Animations = require(game.ReplicatedStorage.Animations.Package.AnimationsServer) Animations:Init() local function applyNinjaProfile(player) task.wait(1) -- Apply the profile by name Animations:ApplyAnimationProfile(player, "NinjaProfile") -- Get the currently applied profile name local profileName = Animations:GetAppliedProfileName(player) print("Current profile:", profileName) -- "NinjaProfile" -- Apply different profile for different situations if player:GetRankInGroup(123456) >= 100 then Animations:ApplyAnimationProfile(player, "VIPProfile") endend game.Players.PlayerAdded:Connect(function(player) player.CharacterAdded:Connect(function() applyNinjaProfile(player) end) end) ``` -------------------------------- ### Get and Manage Animation Tracks (LocalScript Lua) Source: https://context7.com/wrello/animations/llms.txt This client-side snippet shows how to retrieve animation track objects for detailed control and monitoring. It covers getting specific tracks, modifying their properties (e.g., Looped, Priority), connecting to track events like 'Stopped', and playing them. It also demonstrates getting nested tracks, checking if an animation is playing on a specific rig, and waiting for an animation to start with a timeout. Dependencies include the `AnimationsClient` module from `game.ReplicatedStorage.Animations.Package.AnimationsClient`. ```lua -- In a LocalScript local Animations = require(game.ReplicatedStorage.Animations.Package.AnimationsClient) Animations:Init({AutoLoadAllPlayerTracks = true}) Animations:AwaitAllTracksLoaded() -- Get animation track reference local jumpTrack = Animations:GetTrack("Jump") if jumpTrack then jumpTrack.Looped = false jumpTrack.Priority = Enum.AnimationPriority.Action -- Connect to track events jumpTrack.Stopped:Connect(function() print("Jump animation finished") end) jumpTrack:Play() end -- Get nested track local swordAttack = Animations:GetTrack({"Sword", "AttackCombo", 1}) if swordAttack then print("Track length:", swordAttack.Length) print("Is playing:", swordAttack.IsPlaying) end -- Check for playing animations on a rig local enemyCharacter = workspace:WaitForChild("Enemy") local blockingTrack = Animations:FindFirstRigPlayingTrack(enemyCharacter, "Blocking") if blockingTrack then print("Enemy is blocking!") end -- Wait for an animation to start playing with timeout local attackTrack = Animations:WaitForRigPlayingTrack(enemyCharacter, "Attack", 2) if attackTrack then print("Enemy started attacking!") else print("Timeout: Enemy didn't attack within 2 seconds") end ``` -------------------------------- ### Initialize AnimationsServer for Roblox Source: https://context7.com/wrello/animations/llms.txt Initializes the server-side animations module. It takes an optional configuration table to control features like automatic track loading, debug printing, and custom animation ID application. This function is typically called once when the server starts. ```lua -- In a ServerScript local Players = game:GetService("Players") local Animations = require(game.ReplicatedStorage.Animations.Package.AnimationsServer) -- Initialize with options Animations:Init({ AutoLoadAllPlayerTracks = true, -- Automatically load all player animations on spawn TimeToLoadPrints = true, -- Print loading time information EnableAutoCustomRBXAnimationIds = false, -- Apply custom Roblox animation IDs AnimatedObjectsDebugMode = false -- Enable debug prints for animated objects }) -- Handle player joining local function onPlayerAdded(player) Animations:AwaitAllTracksLoaded(player) print("Finished loading animations for", player.Name) end for _, player in ipairs(Players:GetPlayers()) do task.spawn(onPlayerAdded, player) end Players.PlayerAdded:Connect(onPlayerAdded) ``` -------------------------------- ### Monitor Animation Pre-loading Progress (Roblox Lua) Source: https://context7.com/wrello/animations/llms.txt This snippet shows how to monitor the progress of animation pre-loading using ContentProvider. It connects to the `PreloadAsyncProgressed` signal to receive updates on the loading status and provides examples for both server-side and client-side monitoring. The `AwaitPreloadAsyncFinished` function can be used to wait until all animations are loaded. ```lua -- In a ServerScript local Animations = require(game.ReplicatedStorage.Animations.Package.AnimationsServer) -- Connect to progress signal before initialization local loadedCount = 0 Animations.PreloadAsyncProgressed:Connect(function(n, total, loadedAnimInstance) loadedCount = n print(string.format("Pre-loading: %d/%d (%.1f%%)", n, total, (n/total)*100)) print("Loaded:", loadedAnimInstance:GetFullName()) end) -- Initialize (this will trigger pre-loading) Animations:Init({TimeToLoadPrints = true}) -- Wait for all animations to be pre-loaded local allLoadedInstances = Animations:AwaitPreloadAsyncFinished() print("Pre-loading complete! Loaded", #allLoadedInstances, "animations") -- In a LocalScript (client-side monitoring) local AnimationsClient = require(game.ReplicatedStorage.Animations.Package.AnimationsClient) local progressBar = script.Parent.LoadingBar AnimationsClient.PreloadAsyncProgressed:Connect(function(n, total, loadedAnimInstance) progressBar.Size = UDim2.new(n/total, 0, 1, 0) progressBar.Text = string.format("%d/%d", n, total) end) AnimationsClient:Init() local loadedAnims = AnimationsClient:AwaitPreloadAsyncFinished() print("Client finished pre-loading", #loadedAnims, "animations") progressBar.Text = "Complete!" ``` -------------------------------- ### Get Animation ID Strings (Roblox Lua) Source: https://context7.com/wrello/animations/llms.txt This snippet demonstrates how to retrieve asset ID strings for animations defined in the AnimationIds module. It works on both server and client scripts and allows fetching IDs by rig type and animation path, including nested animations. The retrieved ID strings can be used to create Animation instances or for custom logic like getting marker times. ```lua -- In a ServerScript or LocalScript local Animations = require(game.ReplicatedStorage.Animations.Package.AnimationsServer) Animations:Init() -- Get animation ID string by rig type and path local jumpAnimId = Animations:GetAnimationIdString("Player", "Jump") print(jumpAnimId) -- "rbxassetid://656117878" -- Get nested animation ID local swordAttackId = Animations:GetAnimationIdString("Player", "Sword.AttackCombo.1") print(swordAttackId) -- "rbxassetid://3456781" -- Get animation ID for custom rig type local monsterAttackId = Animations:GetAnimationIdString("BigMonster", "Attack") print(monsterAttackId) -- "rbxassetid://4567890" -- Use the ID string for custom purposes local animInstance = Instance.new("Animation") animInstance.AnimationId = jumpAnimId -- Can be used with GetTimeOfMarker local attackAnimId = Animations:GetAnimationIdString("Player", "Sword.Attack") local markerTime = Animations:GetTimeOfMarker(attackAnimId, "HitStart") print("Hit starts at:", markerTime) ``` -------------------------------- ### Play Animation on Server (Lua) Source: https://github.com/wrello/animations/blob/main/docs/basic-usage.md Plays an animation on the server for a given player. This script requires the `AnimationsServer` module and initializes it with optional configuration. It handles loading and playing tracks, ensuring animations are ready before playback. ```lua -- In a ServerScript local Players = game:GetService("Players") local Animations = require(game.ReplicatedStorage.Animations.Package.AnimationsServer) Animations:Init({ AutoLoadAllPlayerTracks = true, -- Defaults to false TimeToLoadPrints = true -- Defaults to true }) local function onPlayerAdded(player) Animations:AwaitAllTracksLoaded(player) print("Finished loading animations for", player.Name) -- Roblox's r15 ninja jump animation is looped. -- `AnimationTrack.Looped = false` doesn't replicate to clients, so -- it is impossible to make this not loop from the server. print("Playing looped ninja jump animation for", player.Name) Animations:PlayTrack(player, "Jump") end for _, player in ipairs(Players:GetPlayers()) do task.spawn(onPlayerAdded, player) end Players.PlayerAdded:Connect(onPlayerAdded) ``` -------------------------------- ### Register and Load Player Animation Tracks (Lua) Source: https://context7.com/wrello/animations/llms.txt This snippet demonstrates how to initialize the animation system, register player characters, and load all animation tracks for a player. It covers automatic registration on character spawn, manual registration of custom rigs, loading all tracks at once, awaiting their completion, and loading specific animation paths. Dependencies include the `AnimationsServer` module from `game.ReplicatedStorage.Animations.Package.AnimationsServer`. ```lua -- In a ServerScript local Animations = require(game.ReplicatedStorage.Animations.Package.AnimationsServer) Animations:Init() local function setupPlayerAnimations(player) -- Automatic registration happens on character spawn -- But you can manually register custom rigs local character = player.Character or player.CharacterAdded:Wait() -- Load all animation tracks at once Animations:LoadAllTracks(player) -- Wait for all tracks to be loaded Animations:AwaitAllTracksLoaded(player) -- Check if tracks are loaded if Animations:AreAllTracksLoaded(player) then print("All tracks loaded for", player.Name) end -- Load only specific animation paths Animations:LoadTracksAt(player, "Sword") Animations:AwaitTracksLoadedAt(player, "Sword") print("Sword animations ready for", player.Name) end game.Players.PlayerAdded:Connect(function(player) player.CharacterAdded:Connect(function() setupPlayerAnimations(player) end) end) ``` -------------------------------- ### Play Animation on Client (Lua) Source: https://github.com/wrello/animations/blob/main/docs/basic-usage.md Plays an animation on the client for the local player. This script utilizes the `AnimationsClient` module and initializes it with similar configuration options as the server script. It focuses on client-side control, allowing modifications like `Looped = false`. ```lua -- In a LocalScript local Animations = require(game.ReplicatedStorage.Animations.Package.AnimationsClient) Animations:Init({ AutoLoadAllPlayerTracks = true, -- Defaults to false TimeToLoadPrints = true -- Defaults to true }) local player = game.Players.LocalPlayer local function onCharacterAdded(char) Animations:AwaitAllTracksLoaded() print("Finished loading client animations") Animations:GetTrack("Jump").Looped = false -- Roblox's r15 ninja jump animation is looped. while true do print("Playing ninja jump client animation") Animations:PlayTrack("Jump") task.wait(3) end end if player.Character then onCharacterAdded(player.Character) end player.CharacterAdded:Connect(onCharacterAdded) ``` -------------------------------- ### Client-Side Rig Animation Control (Lua) Source: https://context7.com/wrello/animations/llms.txt This script illustrates the client-side animation management for rigs that do not replicate to the server. It covers initializing the client system, registering local rigs, loading animations, and playing them with specific playback controls like loading animations by path. ```lua -- In a LocalScript local Animations = require(game.ReplicatedStorage.Animations.Package.AnimationsClient) Animations:Init() local function createLocalPet() local petRig = game.ReplicatedStorage.PetTemplate:Clone() petRig.Parent = workspace -- Register the client-side rig Animations:RegisterRig(petRig, "Pet") -- Wait for registration Animations:AwaitRigRegistered(petRig) -- Load animations for this rig Animations:LoadAllRigTracks(petRig) Animations:AwaitAllRigTracksLoaded(petRig) -- Check loading status if Animations:AreAllRigTracksLoaded(petRig) then print("Pet animations loaded") end -- Play animations on the rig Animations:PlayRigTrack(petRig, "Idle") task.wait(3) -- Load and play specific animation paths Animations:LoadRigTracksAt(petRig, "Actions") Animations:AwaitRigTracksLoadedAt(petRig, "Actions") Animations:PlayRigTrack(petRig, "Actions.Sit") -- Stop rig animations Animations:StopRigTrack(petRig, "Idle", 0.5) Animations:StopRigPlayingTracks(petRig) end createLocalPet() ``` -------------------------------- ### Configure Animation IDs (Lua) Source: https://github.com/wrello/animations/blob/main/docs/basic-usage.md Configures animation IDs for different player rig types and actions. This script should be placed inside `ReplicatedStorage.Animations.Deps.AnimationIds`. It defines a table mapping actions like 'Jump' to specific Roblox animation IDs. ```lua -- Inside of `ReplicatedStorage.Animations.Deps.AnimationIds` local ninjaJumpR15AnimationId = 656117878 local AnimationIds = { Player = { -- Rig type of "Player" (required for any animations that will run on player characters) Jump = ninjaJumpR15AnimationId -- Path of "Jump" } } return AnimationIds ``` -------------------------------- ### Server-Side NPC/Monster Rig Animation Control (Lua) Source: https://context7.com/wrello/animations/llms.txt This script demonstrates how to initialize the server-side animation system, register a custom monster rig, load its animations, and play them in a loop. It handles rig registration, checks, loading, and playback control for server-replicated entities. ```lua -- In a ServerScript local Animations = require(game.ReplicatedStorage.Animations.Package.AnimationsServer) Animations:Init() local function spawnAndAnimateMonster() local monsterRig = workspace.MonsterTemplate:Clone() monsterRig.Parent = workspace -- Register the rig with a custom rig type Animations:Register(monsterRig, "BigMonster") -- Check if registered if Animations:IsRegistered(monsterRig) then print("Monster registered successfully") end -- Load all animations for this rig type Animations:LoadAllTracks(monsterRig) Animations:AwaitAllTracksLoaded(monsterRig) -- Play monster animations while monsterRig.Parent do Animations:PlayTrack(monsterRig, "Walk") task.wait(3) Animations:PlayTrack(monsterRig, "Attack") task.wait(2) Animations:StopPlayingTracks(monsterRig, 0.5) task.wait(1) end end task.spawn(spawnAndAnimateMonster) ``` -------------------------------- ### Initialize AnimationsClient for Roblox Source: https://context7.com/wrello/animations/llms.txt Initializes the client-side animations module for managing local player animations. It accepts configuration options similar to the server-side initialization, controlling features like automatic track loading and debug output. This is intended to be used in a LocalScript. ```lua -- In a LocalScript local Animations = require(game.ReplicatedStorage.Animations.Package.AnimationsClient) local player = game.Players.LocalPlayer -- Initialize with options Animations:Init({ AutoLoadAllPlayerTracks = true, -- Automatically load all player animations TimeToLoadPrints = true, -- Print loading time information EnableAutoCustomRBXAnimationIds = false, -- Apply custom Roblox animation IDs AnimatedObjectsDebugMode = false -- Enable debug prints for animated objects }) -- Handle character spawn local function onCharacterAdded(char) Animations:AwaitAllTracksLoaded() print("Finished loading client animations") -- Animation tracks are now ready to use Animations:GetTrack("Jump").Looped = false end if player.Character then onCharacterAdded(player.Character) end player.CharacterAdded:Connect(onCharacterAdded) ``` -------------------------------- ### Dynamic Animation Switching with Track Aliases (Lua) Source: https://context7.com/wrello/animations/llms.txt This script demonstrates how to set up and use track aliases to dynamically switch between different animation sets for weapons or other character actions without modifying the core animation logic. It requires the AnimationsServer module and handles player-specific animation states. ```lua -- In a ServerScript local Animations = require(game.ReplicatedStorage.Animations.Package.AnimationsServer) Animations:Init({AutoLoadAllPlayerTracks = true}) local function setupWeaponSystem(player) Animations:AwaitAllTracksLoaded(player) local currentWeapon = "Fists" -- Set up aliases for dynamic weapon switching local heavyAttackAlias = "HeavyAttack" local comboAlias = "Combo" local function updateWeaponAliases(weaponName) currentWeapon = weaponName local weaponPath = weaponName .. "Combat" -- Set aliases that point to weapon-specific animations Animations:SetTrackAlias(player, heavyAttackAlias, weaponPath) Animations:SetTrackAlias(player, comboAlias, weaponPath) print("Switched to", weaponName, "animations") end -- Initialize with fists updateWeaponAliases("Fists") -- Play using alias - automatically uses "FistsCombat.HeavyAttack" Animations:PlayTrackFromAlias(player, heavyAttackAlias) task.wait(2) -- Switch to sword updateWeaponAliases("Sword") -- Play using same alias - now uses "SwordCombat.HeavyAttack" Animations:PlayTrackFromAlias(player, heavyAttackAlias) -- Get track from alias local comboTrack = Animations:GetTrackFromAlias(player, comboAlias) -- Stop track using alias Animations:StopTrackFromAlias(player, heavyAttackAlias, 0.3) -- Remove alias when no longer needed Animations:RemoveTrackAlias(player, heavyAttackAlias) end game.Players.PlayerAdded:Connect(function(player) player.CharacterAdded:Connect(function() setupWeaponSystem(player) end) end) ``` -------------------------------- ### Control Animation Playback: Play and Stop Tracks (Lua) Source: https://context7.com/wrello/animations/llms.txt This snippet illustrates how to control animation playback, including playing animations with custom fade times, weights, and speeds, as well as stopping specific tracks or all playing tracks. It also shows how to play nested animation paths and retrieve currently playing tracks. It requires `AnimationsServer` and can be configured with `AutoLoadAllPlayerTracks`. Dependencies include the `AnimationsServer` module from `game.ReplicatedStorage.Animations.Package.AnimationsServer`. ```lua -- In a ServerScript local Animations = require(game.ReplicatedStorage.Animations.Package.AnimationsServer) Animations:Init({AutoLoadAllPlayerTracks = true}) local function demonstrateAnimationControl(player) Animations:AwaitAllTracksLoaded(player) -- Play animation with default settings local jumpTrack = Animations:PlayTrack(player, "Jump") -- Play with custom fade time, weight, and speed local runTrack = Animations:PlayTrack( player, "Run", 0.5, -- fadeTime: smooth transition 1.0, -- weight: full influence 1.5 -- speed: 1.5x normal speed ) -- Play nested animation path local dodgeTrack = Animations:PlayTrack(player, {"Dodge", Enum.KeyCode.W}) -- Or using dot notation local swordWalkTrack = Animations:PlayTrack(player, "Sword.Walk") task.wait(2) -- Stop specific track with fade Animations:StopTrack(player, "Jump", 0.3) -- Stop all playing tracks local stoppedTracks = Animations:StopPlayingTracks(player, 0.5) print("Stopped", #stoppedTracks, "tracks") -- Stop tracks of specific priority Animations:StopTracksOfPriority(player, Enum.AnimationPriority.Action, 0.2) -- Get currently playing tracks local playingTracks = Animations:GetPlayingTracks(player) for _, track in ipairs(playingTracks) do print("Playing:", track.Animation.Name) end end game.Players.PlayerAdded:Connect(function(player) player.CharacterAdded:Connect(function() task.wait(1) demonstrateAnimationControl(player) end) end) ``` -------------------------------- ### Equip Animated Tools with Motor6D Attachments (Roblox Lua) Source: https://context7.com/wrello/animations/llms.txt This snippet demonstrates how to equip tools with animated Motor6D attachments for weapon animations. It requires the AnimationsServer module for server-side equipping and AnimationsClient for client-side rigs. The function takes a player, a tool, and a Motor6D object as input and attaches the tool to the character, enabling animations. ```lua -- In a ServerScript local Animations = require(game.ReplicatedStorage.Animations.Package.AnimationsServer) Animations:Init({ AutoLoadAllPlayerTracks = true, AnimatedObjectsDebugMode = true }) local function equipAnimatedSword(player) Animations:AwaitAllTracksLoaded(player) -- Get the tool and motor6d local swordTool = game.ReplicatedStorage.SwordTool:Clone() local swordMotor6D = game.ReplicatedStorage.AnimatedObjects.SwordMotor6D -- Equip the tool with animated attachment Animations:EquipAnimatedTool(player, swordTool, swordMotor6D) -- The tool is now equipped and the Motor6D is attached -- Animation will properly animate the sword Animations:PlayTrack(player, "Sword.Walk") end game.Players.PlayerAdded:Connect(function(player) player.CharacterAdded:Connect(function() task.wait(1) equipAnimatedSword(player) end) end) -- Client-side rig version -- In a LocalScript local AnimationsClient = require(game.ReplicatedStorage.Animations.Package.AnimationsClient) AnimationsClient:Init() local function equipToolOnClientRig() local localRig = workspace.ClientPet AnimationsClient:RegisterRig(localRig, "Pet") AnimationsClient:LoadAllRigTracks(localRig) AnimationsClient:AwaitAllRigTracksLoaded(localRig) local toolToEquip = game.ReplicatedStorage.PetAccessory:Clone() local motor6d = game.ReplicatedStorage.AnimatedObjects.AccessoryMotor -- Equip on client rig (does not replicate to server) AnimationsClient:EquipRigAnimatedTool(localRig, toolToEquip, motor6d) end equipToolOnClientRig() ``` -------------------------------- ### Attach and Detach Animated Objects (Lua) Source: https://context7.com/wrello/animations/llms.txt This snippet demonstrates how to manage animated objects that attach to character models during animations, such as weapons or accessories. It covers both automatic attachment/detachment based on animation configuration and manual control. Debugging can be enabled for insights. ```lua -- First, configure animated objects in AnimationIds -- Inside ReplicatedStorage.Animations.Deps.AnimationIds local HasAnimatedObject = require(script.Parent.Parent.Package.Util.AnimationIdsUtil).HasAnimatedObject local AnimationIds = { Player = { Sword = { -- Auto-attach sword when walking Walk = HasAnimatedObject(2345678, "Sword", { AutoAttach = true, AutoDetach = false }), -- Auto-attach for attack combo AttackCombo = HasAnimatedObject({ [1] = 3456781, [2] = 3456782, [3] = 3456783 }, "Sword", { AutoAttach = true, AutoDetach = true -- Auto-detach when animation ends }) } } } return AnimationIds -- In a ServerScript local Animations = require(game.ReplicatedStorage.Animations.Package.AnimationsServer) Animations:Init({ AutoLoadAllPlayerTracks = true, AnimatedObjectsDebugMode = true -- Enable debug prints }) local function demonstrateAnimatedObjects(player) Animations:AwaitAllTracksLoaded(player) -- Manually attach animated object Animations:AttachAnimatedObject(player, "Sword") task.wait(2) -- Play animation (sword will be animated via Motor6D) Animations:PlayTrack(player, "Sword.Walk") task.wait(3) -- Manually detach animated object Animations:DetachAnimatedObject(player, "Sword") -- When using AutoAttach, the object attaches automatically Animations:PlayTrack(player, "Sword.AttackCombo", 1) -- Sword automatically attaches and animates -- Wait for combo to finish (AutoDetach will remove it) task.wait(3) end game.Players.PlayerAdded:Connect(function(player) player.CharacterAdded:Connect(function() task.wait(1) demonstrateAnimatedObjects(player) end) end) ``` -------------------------------- ### Applying Custom Roblox Animation IDs (Lua) Source: https://context7.com/wrello/animations/llms.txt This script shows how to override default Roblox character animations (like jump, run, idle) with custom animation IDs. It supports different rig types (R15 and R6) and can apply multiple idle animations. The AnimationsServer module is required. ```lua -- In a ServerScript local Animations = require(game.ReplicatedStorage.Animations.Package.AnimationsServer) Animations:Init() local function applyCustomCharacterAnimations(player) task.wait(1) -- Wait for character to fully load -- Define custom animation IDs for different rig types Animations:ApplyCustomRBXAnimationIds(player, { [Enum.HumanoidRigType.R15] = { jump = 656117878, -- Ninja jump animation run = 616163682, -- Ninja run animation idle = { Animation1 = 656117400, -- Ninja idle 1 Animation2 = 656118341 -- Ninja idle 2 }, walk = 656121766, fall = 656115606, swim = 656119721, swimIdle = 656118877, climb = 656114359 }, [Enum.HumanoidRigType.R6] = { walk = 5432198, -- R6 uses walk instead of run jump = 5432199 } }) print("Applied custom animations for", player.Name) end game.Players.PlayerAdded:Connect(function(player) player.CharacterAdded:Connect(function() applyCustomCharacterAnimations(player) end) end) ``` -------------------------------- ### Configure AnimationIds Module for Roblox Source: https://context7.com/wrello/animations/llms.txt Defines animation IDs for different rig types in a structured manner, supporting simple IDs, nested paths for directional or sequential animations, and organization by weapon types. This configuration is crucial for the Animations module to map actions to specific animation assets. ```lua -- Inside ReplicatedStorage.Animations.Deps.AnimationIds local AnimationIds = { Player = { -- Rig type for player characters -- Simple animation ID Jump = 656117878, -- Nested animation paths Dodge = { [Enum.KeyCode.W] = 1234567, [Enum.KeyCode.S] = 1234568, [Enum.KeyCode.A] = 1234569, [Enum.KeyCode.D] = 1234570, }, -- Weapon animations Sword = { Walk = 2345678, Run = 2345679, Idle = 2345680, AttackCombo = { [1] = 3456781, [2] = 3456782, [3] = 3456783 } } }, -- Custom rig types for NPCs BigMonster = { Attack = 4567890, Walk = 4567891, Idle = 4567892 } } return AnimationIds ``` -------------------------------- ### Retrieve Animation Marker Timestamps (Lua) Source: https://context7.com/wrello/animations/llms.txt This snippet shows how to configure animations to support marker times and retrieve specific marker timestamps from playing animation tracks. It's useful for synchronizing gameplay events like hit detection or effects with animation events. Ensure MarkerTimes is set to true in AnimationIds configuration. ```lua -- First, configure animations with MarkerTimes in AnimationIds -- Inside ReplicatedStorage.Animations.Deps.AnimationIds local HasProperties = require(script.Parent.Parent.Package.Util.AnimationIdsUtil).HasProperties local AnimationIds = { Player = { Sword = { Attack = HasProperties(1234567, { Priority = Enum.AnimationPriority.Action, MarkerTimes = true -- Enable marker support }) } } } return AnimationIds -- In a ServerScript local Animations = require(game.ReplicatedStorage.Animations.Package.AnimationsServer) Animations:Init({AutoLoadAllPlayerTracks = true}) local function handleSwordAttack(player) Animations:AwaitAllTracksLoaded(player) -- Play the attack animation local attackTrack = Animations:PlayTrack(player, "Sword.Attack") -- Get time of specific marker in the animation local hitStartTime = Animations:GetTimeOfMarker(attackTrack, "HitStart") local hitEndTime = Animations:GetTimeOfMarker(attackTrack, "HitEnd") if hitStartTime then print("Hit detection starts at:", hitStartTime, "seconds") -- Schedule hit detection at marker time task.delay(hitStartTime, function() print("Checking for hits...") -- Perform hit detection logic end) end -- Alternative: Get marker time using animation ID string local animIdStr = Animations:GetAnimationIdString("Player", "Sword.Attack") local impactTime = Animations:GetTimeOfMarker(animIdStr, "Impact") if impactTime then task.delay(impactTime, function() print("Impact effect at", impactTime) -- Play impact effects end) end end game.Players.PlayerAdded:Connect(function(player) player.CharacterAdded:Connect(function() task.wait(2) handleSwordAttack(player) end) end) ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.