local player = game.Players.LocalPlayer
local mouse = player:GetMouse()
local Animate
local Humanoid = player.Character:FindFirstChild('Humanoid')
mouse.KeyDown:Connect(function(Key)
Key = Key:lower()
if Key == "c" then
local Animation = Instance.new("Animation", player.Character)
Animation.AnimationId = "rbxassetid://3555353330"
Animate = Humanoid:LoadAnimation(Animation)
Animate:Play()
end
end)
if mouse.KeyDown:Connect(function(Key)
Key = Key:lower()
if Key == "c" then
Animate:Destroy()
end
end
end)
It keeps saying "expected ')' (to close '(' at line 15), got 'end'
Any ideas on how I could fix this or just fix the script in general? Its meant to be so every-time you press "c" your character crouches with a custom animation then when you press "c" again it stops the crouching animation and makes you stand like normal. I'm very NEW to scripting so sorry if I look stupid as hell.
edit
After looking at the comments I changed the script to use UserInputService but still have no idea
local player = game.Players.LocalPlayer
local mouse = player:GetMouse()
local Animate
local Humanoid = player.Character:FindFirstChild('Humanoid')
local UIS = game:GetService("UserInputService")
UIS.InputBegan:connect(function(Input)
local MouseInput = Input.UserInputType
local KeyCode = Input.KeyCode
if KeyCode == Enum.KeyCode.C then
local Animation = Instance.new("Animation", player.Character)
Animation.AnimationId = "rbxassetid://3555353330"
Animate = Humanoid:LoadAnimation(Animation)
Animate:Play()
end
end
if KeyCode == Enum.KeyCode.C then
Animate:Stop()
end
end)

4 comments
dont use keydown use UserInputService
^
I changed it to use UserInputService but still don't really know, could any of you help?
lol it'd be cool if people actually helped instead of just correcting deprecated code