Hi, I am trying to make a basic crouch script for my game.
What’s happening is if I crouch, and then try to move in any direction, I can not move until uncrouched. The weird thing is though, if I move first, and then press crouch, I can move freely and crouch at the same time
I have searched up through quite a few forums looking for an answer. I’ve tried changing the animation type to action, doesn’t work. Movement? Doesn’t work. Core? Doesn’t work.
Here is the code I wrote for this script:
task.wait()
local uis = game:GetService("UserInputService")
local char = script.Parent
local humanoid = char:WaitForChild("Humanoid")
local animator = humanoid.Animator
local crouch = script.Animation
local track = animator:LoadAnimation(crouch)
uis.InputEnded:Connect(function(rem, proc)
if proc then return end
if rem.KeyCode == Enum.KeyCode.LeftControl then
task.wait()
print("Crouch Stop")
track:Stop()
end
end)
uis.InputBegan:Connect(function(input, proc)
if proc then return end
while uis:IsKeyDown(Enum.KeyCode.LeftControl) do
task.wait()
print("Crouch")
track:Play()
end
end)
If anyone knows why this is happening, please tell me.