I’m working on a movement system for a game I’m working on, I am trying to make it so that when a player moves when crouched it will stop the crouching idle animation. I’ve tried all I can think of to detect player movement but it only works when the player is moving before crouching
function startcrouch()
local goal = { }
crouched = true
hum.WalkSpeed = 8
goal.CameraOffset = Vector3.new(0, -.5, 0)
goal.HipHeight = -1.1
local ct = ts:Create(hum, crouchTI, goal)
ct:Play()
ci:Play()
end
function stopcrouch()
local goal = { }
wait(0.08)
crouched = false
hum.WalkSpeed = 11
goal.CameraOffset = Vector3.new(0, 0, 0)
goal.HipHeight = 0
local ct = ts:Create(hum, crouchTI, goal)
ct:Play()
ci:Stop()
end
uis.InputBegan:connect(function(input)
if sprinting and input.KeyCode == Enum.KeyCode.C and not sliding and hum.MoveDirection ~= Vector3.new(0, 0, 0) then
startSlide()
end
if input.KeyCode == Enum.KeyCode.C and not crouched and not sprinting and not debounce then
debounce = true
startcrouch()
end
if input.KeyCode == Enum.KeyCode.LeftShift and not sliding and not crouched and not sprinting then
--sprinting = true
end
end)
uis.InputEnded:connect(function(input)
if input.KeyCode == Enum.KeyCode.C and crouched then
stopcrouch()
wait(0.5)
debounce = false
end
if input.KeyCode == Enum.KeyCode.C and sliding then
stopSlide()
end
end)