Crouch Walk Animation not playing correctly

How it’s supposed to play:

How it plays:

Some info:

  1. When crouch walk starts playing, crouch idle gets stopped, so it avoids overlapping
  2. Crouch Walk’s animation priority is Movement and Crouch Idle’s priority is Idle

Script:

local plr = game.Players.LocalPlayer
repeat task.wait() until plr.Character
local chr = plr.Character
local hum = chr:FindFirstChild("Humanoid")
local uis = game:GetService("UserInputService")
local anmr = hum.Animator
local runningval = script.Parent.Parent.Values.isRunning
local crouchingval = script.Parent.Parent.Values.isCrouching
local canrun = script.Parent.Parent.Values.canRun
local rs = game:GetService("RunService")
local camera = workspace.CurrentCamera
local CameraShaker = require(game.ReplicatedStorage.Modules.CameraShaker)

local function ShakeCamera(shakeCf)
	camera.CFrame = camera.CFrame * shakeCf
end
local renderPriority = Enum.RenderPriority.Camera.Value + 1
local camShake = CameraShaker.new(renderPriority, ShakeCamera)

camShake:Start()

local crossahir = plr.PlayerGui.GGUI.Crosshair

local function tweencsize(size)
	if size == "big" then

		crossahir:TweenSize(
			UDim2.new(0.057,0,0.112,0),
			Enum.EasingDirection.In,
			Enum.EasingStyle.Sine,
			0.15,
			true
		)

		crossahir:TweenPosition(
			UDim2.new(0.471,0,0.463,0),
			Enum.EasingDirection.In,
			Enum.EasingStyle.Sine,
			0.15,
			true
		)

	else
		if size == "normal" then


			crossahir:TweenSize(
				UDim2.new(0.027,0,0.036,0),
				Enum.EasingDirection.In,
				Enum.EasingStyle.Sine,
				0.15,
				true
			)

			crossahir:TweenPosition(
				UDim2.new(0.482,0,0.479,0),
				Enum.EasingDirection.In,
				Enum.EasingStyle.Sine,
				0.15,
				true
			)

		else
			if size == "small" then



				crossahir:TweenSize(
					UDim2.new(0.023,0,0.023,0),
					Enum.EasingDirection.In,
					Enum.EasingStyle.Sine,
					0.15,
					true
				)

				crossahir:TweenPosition(
					UDim2.new(0.49,0,0.487,0),
					Enum.EasingDirection.In,
					Enum.EasingStyle.Sine,
					0.15,
					true
				)

			end

		end

	end
end


local changevalrem = game.ReplicatedStorage.Remotes.ChangeVal

local crouch = hum.Animator:LoadAnimation(game.ReplicatedStorage.Anims.Crouch)
local cwalk = hum.Animator:LoadAnimation(game.ReplicatedStorage.Anims.CrouchWalk)

local function startrunning(key, _gameProcessed)
	if key.KeyCode == Enum.KeyCode.LeftShift and crouchingval.Value == false and canrun.Value == true then
		hum.WalkSpeed = 16
		runningval.Value = true
		canrun.Value = true
		changevalrem:FireServer(plr, runningval,runningval, true)
		changevalrem:FireServer(plr, canrun,canrun, true)
	else
		if key.KeyCode == Enum.KeyCode.LeftControl and runningval.Value == false then
			canrun.Value = false
			crouchingval.Value = true	
			crouch:Play()
			chr.HumanoidRootPart.Anchored = false
			hum.WalkSpeed = 4
			tweencsize("small")
			changevalrem:FireServer(plr, crouchingval, crouchingval, true)
			changevalrem:FireServer(plr, canrun, canrun, false)
		end
	end
	
end

local function stoprunning(key, _gameProcessed)
	if key.KeyCode == Enum.KeyCode.LeftShift and crouchingval.Value == false and runningval.Value == true then
		hum.WalkSpeed = 7
		runningval.Value = false
		canrun.Value = true
		changevalrem:FireServer(plr, runningval,runningval, false)
		changevalrem:FireServer(plr, canrun,canrun, true)
	else
		if key.KeyCode == Enum.KeyCode.LeftControl and runningval.Value == false then
			crouchingval.Value = false
			canrun.Value = true
			crouch:Stop()
			cwalk:Stop()
			chr.HumanoidRootPart.Anchored = false
			hum.WalkSpeed = 7
			tweencsize("normal")
			changevalrem:FireServer(plr, crouchingval,crouchingval, false)
			changevalrem:FireServer(plr, canrun,canrun, true)
		end
	end
end

uis.InputBegan:Connect(startrunning)
uis.InputEnded:Connect(stoprunning)


rs.RenderStepped:Connect(function()
	if hum.MoveDirection.Magnitude > 0 then
	if hum.WalkSpeed == 7 then
			camShake:Shake(CameraShaker.Presets.Walk)
		else
			if hum.WalkSpeed > 7 then
				camShake:Shake(CameraShaker.Presets.RushedWalk)
			else
				if hum.WalkSpeed < 7 then
					camShake:Shake(CameraShaker.Presets.SlowedWalk)
				end
			end
		end
	else
	end
	if crouchingval.Value == true then
		if hum.MoveDirection.Magnitude > 0 then
			cwalk:Play()
			crouch:Stop()
		else
			if crouch.IsPlaying == false then
				crouch:Play()
			end
			cwalk:Stop()
			end
		end
end)

local function uneq()
	hum:UnequipTools()
end
local cas = game:GetService("ContextActionService")

cas:BindAction("UnequipTools", uneq, false, Enum.KeyCode.X)
1 Like

What I think is the case is your crouch animation is merging with your walk animation.

1 Like

Read what I said in info. (charsss)

1 Like

Just for the heck of it to see what it would do maybe try making both of their priorities Action? I have no idea if that’ll work but it’s worth a shot.

Already tried, it didn’t work though.

1 Like