Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How do I make an animation play while another one is already active?

I made a crouching animation for a game I'm working in which you hold ''c'' your character gets in a low position and their walk speed is slow. I have already made a walking animation for it where if you try moving while you're in that crouching position only your legs move, But I can't find a way to implant that crouch walk animation into the game. Any help?

Here's the crouch animation:

local player = game.Players.LocalPlayer
local mouse = player:GetMouse()
local Animate 
local Humanoid = player.Character:FindFirstChild('Humanoid')

mouse.KeyDown:Connect(function(Key) 
 if Key == "c" then
  local Animation = Instance.new("Animation", player.Character)
  Animation.AnimationId = "rbxassetid://02633068545"
  Animate = Humanoid:LoadAnimation(Animation)
  Animate:Play()
    Humanoid.WalkSpeed = 5.5

 end  
end)

mouse.KeyUp:Connect(function(Key)
 if Key == "c" then
  Animate:Stop()
    Humanoid.WalkSpeed = 16
 end
end)

===================================================================================

Video of what the crouching animation looks like: https://gyazo.com/d427b29ec06f88429bea89ea5f26c6c8

1 answer

✓ Accepted answer

You'll need to utilise AnimationPriority. (Core < Idle < Movement < Action). You can assign an Animation's AnimationPriority in the animation editor, or during runtime with AnimationTrack.Priority. Keep in mind that, when two animations with the same priority play, the most recent played will play on top of the other animation.

I hope this helped!

1 comment

0

Very helpful, thank you!

This discussion is preserved as it was. New answers, comments, and votes are closed.