Here is an example of an animation script.
--Put the animation in the script
local UserInputServise = game:GetService("UserInputService")
local Character = script.Parent
local Humanoid = Character:WaitForChild("Humanoid")
local isRunning = false
local Animation = Humanoid:LoadAnimation(script:WaitForChild("Animation"))
UserInputServise.InputBegan:Connect(function(key)
if key.KeyCode == Enum.KeyCode.C then
if not isRunning then
isRunning = true
Animation:Play()
else
isRunning = false
Animation:Stop()
end
end
end)