This is all I have right now, I got help from some websites n stuff. It makes you crouch, and that's it. You can stand back up, but that's all it does. I'm wanting it to be like: C pressed once = Crouch C pressed twice = Lay C press three times = Stand back up again
local key = "C"
local Player = game.Players.LocalPlayer
local Character = Player.Character
local AnimationID = "6974258690"
local CharAnimation
local ContextActionService = game:GetService("ContextActionService")
local FREEZE_ACTION = "freezeMovement"
local Sens = 0.12
local LastPressed = nil
game:GetService("UserInputService").InputBegan:Connect(function(input)
if input.KeyCode == Enum.KeyCode.C then
local Trig = false
if LastPressed ~= nil then
if tick() - LastPressed <= Sens then
print("Open Menu")
Trig = true
end
end
if not Trig then
LastPressed = tick()
end
end
end)
game:GetService("UserInputService").InputBegan:Connect(function(inputObject, gameProcessedEvent)
if inputObject.KeyCode == Enum.KeyCode[key] then
animation()
end
end)
function animation()
if Character then
local idleanimation = Character:FindFirstChild("AnimationCharacter")
if CharAnimation then
CharAnimation:Stop()
ContextActionService:UnbindAction(FREEZE_ACTION)
end
if idleanimation then
if idleanimation.AnimationId=="rbxassetid://"..AnimationID then
idleanimation:Destroy()
return
end
idleanimation:Destroy()
end
local Animation =Instance.new("Animation",Character)
Animation.Name= "AnimationCharacter"
Animation.AnimationId = "rbxassetid://"..AnimationID
CharAnimation= Character.Humanoid:LoadAnimation(Animation)
CharAnimation:Play()
ContextActionService:BindAction(
FREEZE_ACTION,
function()
return Enum.ContextActionResult.Sink
end,
false,
unpack(Enum.PlayerActions:GetEnumItems())
)
end
end

4 comments
Thank you for your response! Though, when I press C nothing happens. Did I do something wrong? The only thing I didn't understand was the ServerScript part. Do you mean by just a script?
Yes, I do
Well, I put the script in the game, and when I press C once it plays the animation. When I press C again, it plays the 2nd animation, but the 1st one is still playing. It happens again while pressing C a third time. Any fix to this?
Oh, yes. When the player presses C, put "playAnimation:Stop()" and then set the animation ID, and after that put "playAnimation:Play()"