Crouch walking script not working

I tried modifying a script i found that makes you play a crouching animation once u press “c”. I tried to make it so that when you press both “c” and “w” it plays a walking crouch animation. but it didnt work. please tell me what im doing wrong.

local player = game.Players.LocalPlayer
local mouse = player:GetMouse()
local Animate
local Humanoid = player.Character:FindFirstChild(‘Humanoid’)

mouse.KeyDown:Connect(function(Key)
if Key == “c” and Key == “w” then
local Animation = Instance.new(“Animation”, player.Character)
Animation.AnimationId = “rbxassetid://5389650682”
Animate = Humanoid:LoadAnimation(Animation)
Animate:Play()
end
end)

mouse.KeyUp:Connect(function(Key)
if Key == “c” and Key == “w” then
Animate:Stop()
end
end)

1 Like
local player = game.Players.LocalPlayer
local mouse = player:GetMouse()
local Animate
local Humanoid = player.Character:FindFirstChild(‘Humanoid’)

mouse.KeyDown:Connect(function(Key, typing)
   if typing then return end 
   if Key.KeyCode == Enum.KeyCode.c and Key.KeyCode == Enum.KeyCode.q then
         local Animation = Instance.new(“Animation”, player.Character)
         Animation.AnimationId = “rbxassetid://5389650682”
         Animate = Humanoid:LoadAnimation(Animation)
         Animate:Play()
   end
end)

mouse.KeyUp:Connect(function(Key)
if Key.KeyCode == Enum.KeyCode.c and Key.KeyCode == Enum.KeyCode.q then
     Animate:Stop()
   end
end)

Maybe something like this may work, although I haven’t really used InputService that much.

2 Likes

didnt work somehow. it says in the output that c isnt a vil enumitem

Maybe put the c and q Capitalised.

did that
didnt work…
im not sure whats wrong in the script

Why do you need to get players mouse? and Have you called InputService?