I have my crouch Animation ready, But I don't know how to prepare a script for making it keybind. I I want it such that when I press 'c', I can crouch and when I press 'c' again, I can revert back to normal position. Can you please help me for giving me the script for that?
local player = game.Players.LocalPlayer
02 local mouse = player:GetMouse()
03 local Character = player.Character or player.CharacterAdded:Wait()
04 local Humanoid = Character:WaitForChild("Humanoid")
05 local UIS = game:GetService("UserInputService")
06
07 local debounce = false
08 UIS.InputBegan:Connect(function(Input)
09 if Input.KeyCode == Enum.KeyCode.C then
10 if not debounce then
11 debounce = true
12 local Animation = Instance.new("Animation")
13 Animation.AnimationId = "rbxassetid://4851457147"
14 Animation.Parent = player.Character
15 Animate = Humanoid:LoadAnimation(Animation)
16 Animate:Play()
17 else
18 Animate:Stop()
19
20 debounce = false
21 end
22 end
23 end)
``
this is my current script and is not working.

3 comments
Please format your code properly
yes I did it @Twinbrotato
What happens when you run that code and press C? Any errors in output?