Hey. I'm making a gun, and I'm looking for a way for my animation to play when the player is walking too because whenever he's walking the animation stops. Thanks.
Basically you make an animation firstly using animation editor, next you export it and get the id and then use:
01 | local Players = game:GetService( "Players" ) |
02 |
03 | local function onCharacterAdded(character) |
04 | local humanoid = character:WaitForChild( "Humanoid" ) |
05 |
06 | for _, playingTracks in pairs (humanoid:GetPlayingAnimationTracks()) do |
07 | playingTracks:Stop( 0 ) |
08 | end |
09 |
10 | local animateScript = character:WaitForChild( "Animate" ) |
11 | animateScript.run.RunAnim.AnimationId = "rbxassetid://616163682" -- Run |
12 | animateScript.walk.WalkAnim.AnimationId = "rbxassetid://616168032" -- Walk |
13 | animateScript.jump.JumpAnim.AnimationId = "rbxassetid://616161997" -- Jump |
14 | animateScript.idle.Animation 1. AnimationId = "rbxassetid://616158929" -- Idle (Variation 1) |
15 | animateScript.idle.Animation 2. AnimationId = "rbxassetid://616160636" -- Idle (Variation 2) |
credit to the dev form: https://developer.roblox.com/en-us/articles/using-animations-in-games
If you want the animation to play when the character stops walking, simply set the priority of the animation to idle and play the animation however you decide and whenever the character isn't moving and doesn't have a higher priority animation using the parts used for that animation it'll play the animation (if that make sense)