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.
Here's the script
local mouse = player:GetMouse() local Animate local Humanoid = player.Character:FindFirstChild('Humanoid') local UIS = game:GetService("UserInputService") UIS.InputBegan:Connect(function(io, gameProcessEvent) if io.KeyCode == Enum.KeyCode.C then local Animation = Instance.new("Animation", player.Character) Animation.AnimationId = "rbxassetid://your id" Animate = Humanoid:LoadAnimation(Animation) Animate:Play() end end) UIS.InputEnded:Connect(function(io, gameProcessEvent) if io.KeyCode == Enum.KeyCode.C then Animate:Stop() end end)