Need help fix animation Crouch auto play when not move

  1. What do you want to achieve?
    I want fix animation crouch auto play but players isn’t moving, when i moving it stop play crouch animation(Move a bit then stop), when i stand up and crouch back it auto move again
  2. What is the issue? Include screenshots / videos if possible!
    Here is video:

Computer script:

local UIS = game:GetService("UserInputService")
local char = script.Parent
local hum = char:WaitForChild("Humanoid")
local anim = hum:LoadAnimation(script:WaitForChild("Animation"))
local isCrawling = false
local sprint = game.Players.LocalPlayer.PlayerGui.Shift
local mobilesprint = game.Players.LocalPlayer.PlayerGui.Mobile.Run.Sprint

UIS.InputBegan:Connect(function(input)
	if input.KeyCode == Enum.KeyCode.C then
		if not isCrawling then
			mobilesprint.Disabled = true
			hum.CameraOffset = Vector3.new(0,-1,0)
			sprint.Disabled = true
			hum.WalkSpeed = 10
			isCrawling = true
			anim:Play()
			hum.JumpPower = 0
		else
			mobilesprint.Disabled = false
			hum.CameraOffset = Vector3.new(0,0,0)
			sprint.Disabled = false
			hum.WalkSpeed = 16
			anim:Stop()
			isCrawling = false
			hum.JumpPower = 7.159
		end
	end
	local Event = char.Humanoid.Running:Connect(function(speed)
		if speed == 0 then 
			anim:AdjustSpeed(0)
		else
			anim:AdjustSpeed(1)
		end
	end)
end)

Mobile and Ipad script

local UIS = game:GetService("UserInputService").TouchEnabled
local char = game.Players.LocalPlayer.Character
local hum = char:WaitForChild("Humanoid")
local anim = hum:LoadAnimation(script:WaitForChild("Animation"))
local isCrawling = false
local sprint = game.Players.LocalPlayer.PlayerGui.Shift
local button = game.Players.LocalPlayer.PlayerGui.Mobile.Crouch
local mobilesprint = game.Players.LocalPlayer.PlayerGui.Mobile.Run.Sprint

button.MouseButton1Click:Connect(function()
	if not isCrawling then
		anim:Play()
		char.Humanoid.JumpPower = 0
		mobilesprint.Disabled = true
		hum.CameraOffset = Vector3.new(0,-1,0)
		sprint.Disabled = true
		hum.WalkSpeed = 10
		isCrawling = true
	else
		anim:Stop()
		char.Humanoid.JumpPower = 7.159
		mobilesprint.Disabled = false
		hum.CameraOffset = Vector3.new(0,0,0)
		sprint.Disabled = false
		hum.WalkSpeed = 16
		isCrawling = false
	end
	local Event = char.Humanoid.Running:Connect(function(speed)
		if speed == 0 then 
			anim:AdjustSpeed(0)
		else
			anim:AdjustSpeed(1)
		end
	end)
end)

Please if you guys can help, edit a bit about 2 this script for it remove animation crouch auto play when players not moving.

2 Likes

while i was looking for a solution i found this and i had animation.Speed = amount and i decided to try :AdjustSpeed() and it worked so your answer is instead of doing char.Humanoid.Running try MoveDirection

ALSO if you want to stop the checking for player movement dont do local event
at the top of the script do it

Example:

local Event = nil


-- pressing key

Event = game:GetService("RunService").RenderStepped:Connect(function(deltaTime)

	pcall(function()
		if Humanoid.MoveDirection == Vector3.new(0,0,0) then
			Animation:AdjustSpeed(0)
		else
			Animation:AdjustSpeed(1)
		end
	end)

end)


-- end key pressing
Event:Disconnect()
Event = nil

Anyways heres what u need to do

local UIS = game:GetService("UserInputService")
local char = script.Parent
local hum = char:WaitForChild("Humanoid")
local anim = hum:LoadAnimation(script:WaitForChild("Animation"))
local isCrawling = false
local sprint = game.Players.LocalPlayer.PlayerGui.Shift
local mobilesprint = game.Players.LocalPlayer.PlayerGui.Mobile.Run.Sprint

local Event = nil
UIS.InputBegan:Connect(function(input)
	if input.KeyCode == Enum.KeyCode.C and UIS:GetFocusedTextBox() == nil then
		if not isCrawling then
			mobilesprint.Disabled = true
			hum.CameraOffset = Vector3.new(0,-1,0)
			sprint.Disabled = true
			hum.WalkSpeed = 10
			isCrawling = true
			anim:Play()
			hum.JumpPower = 0
		else
			mobilesprint.Disabled = false
			hum.CameraOffset = Vector3.new(0,0,0)
			sprint.Disabled = false
			hum.WalkSpeed = 16
			anim:Stop()
			isCrawling = false
			hum.JumpPower = 7.159
		end
	end
	Event = game:GetService("RunService").RenderStepped:Connect(function()
		
		pcall(function()
			if hum.MoveDirection == Vector3.new(0,0,0) then
				anim:AdjustSpeed(0)
			else
				anim:AdjustSpeed(1)
			end
		end)
		
		
	end)
end)
1 Like