Right now I can Play the Animation with "c" and Stop the Animation with "x". But when I change "x" for "c", It does like both play and stop at the same time. How can I make it so that I can Play the animation with "c" and only if I played the animation can I then stop the animation with "c".
--LocalPlayer's Camera
local player = game.Players.LocalPlayer
local camera = workspace.CurrentCamera
local character = player.Character
--Crouch Animation
local mouse = player:GetMouse()
local Animate
local Humanoid = player.Character:FindFirstChild('Humanoid')
local CrouchAnimation = game.StarterPlayer.StarterPlayerScripts.Animate
:WaitForChild("crouch"):FindFirstChild("CrouchAnim")
mouse.KeyDown:Connect(function(Key)
if Key == "c" then
Animate = Humanoid:LoadAnimation(CrouchAnimation)
Humanoid.CameraOffset = Vector3.new(0, -1.2, -1.5)
Animate:Play()
print("Crouched")
mouse.KeyDown:Connect(function(Key)
if Key == "x" then
Humanoid.CameraOffset = Vector3.new(0, 0.2, -1.5)
Animate:Stop()
print("unCrouched")
end
end)
end
end)

1 comment
Wait I just thought of how I can do this. If it works, I'll post the Answer!