Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How to make an animation play and not stop when a player is walking?

Asked by
XDvvvDX 186
4 years ago
Edited 4 years ago

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.

2 answers

Log in to vote
0
Answered by 4 years ago

Basically you make an animation firstly using animation editor, next you export it and get the id and then use:

01local Players = game:GetService("Players")
02 
03local 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.Animation1.AnimationId = "rbxassetid://616158929"    -- Idle (Variation 1)
15    animateScript.idle.Animation2.AnimationId = "rbxassetid://616160636"    -- Idle (Variation 2)
View all 26 lines...

credit to the dev form: https://developer.roblox.com/en-us/articles/using-animations-in-games

Ad
Log in to vote
0
Answered by 4 years ago

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)

Answer this question