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

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

Asked by 5 years ago

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

Log in to vote
1
Answered by
BenSBk 781 Moderation Voter
5 years ago
Edited 5 years ago

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!

0
Very helpful, thank you! Incinerxte 2 — 5y
Ad

Answer this question