So I have a crouching script that makes the player crouch when he presses “S” but the problem is that when you move to the left or right, he will play another animation instead of the crouching one.
Here is the script :
local plr = game.Players.LocalPlayer
local char = plr.Character
local hum = char:FindFirstChild("Humanoid")
local uis = game:GetService("UserInputService")
local Animator = hum:WaitForChild("Animator")
local CrouchAnim = game.ReplicatedStorage.Animations["Crouch Start-Up"]
local CrouchIdleAnim = game.ReplicatedStorage.Animations["Crouch Idle"]
local GetDownAnimation = Animator:LoadAnimation(CrouchAnim)
local LoopIdleAnimation = Animator:LoadAnimation(CrouchIdleAnim)
if input.KeyCode == Enum.KeyCode.S then
hum.WalkSpeed = 0
for _, animation in ipairs(hum:GetPlayingAnimationTracks()) do
if animation.Priority == Enum.AnimationPriority.Movement then
hum.WalkSpeed = 16
The animation priority for crouch needs to be higher than the walking ones, where the walking ones would be core or movement, crouch would be action1, action2, action3, or action4.
Is there any way to change animation Priority in a script?
Animation.Priority = Enum.AnimationPriority.Action1
Ok so it’s still kinda broken. When I crouch and I walk left or right, then the idle animations starts playing and if I let go of crouching, then I will start walking. I made the idle animation priority to movement.
Idle should be idle, movement should be core, and crouch should be action1 or above
Still doesn’t work. I changed Idle animation to Idle, moving to left and right to movement and crouch to Action and still doesn’t work.
Could have to do with too many animations playing at once! You might need to disable walking animation while crouching, or add new walking crouch animations to play instead!
Let’s just disable idle and walking animations when crouching is enabled. How can we do that?
Just play the animation with a higher animation weight set
if crouch then
if walkinganim then
This just makes the crouch animation snap immediately to idle
How am I supposed to do that tho? Should I use a bool value for when the player walks or is idle?
Are you using custom characters all together or are you modifying the defalt Roblox PlayerModule and/or its scripts?
for i,v in pairs(character.Humanoid.Animator:GetPlayingAnimationTracks()) do
I forgot if the function is :Stop() but this will basically stop every single animation playing on the humanoid’s animator
this still doesn’t work. Maybe I can show a video of the problem?