Basically, when a player presses p I want it to run a animation. When I press p, it doesn't run the animation. The animation is just a simple punching animaton.
local Player = game.Players.LocalPlayer
local Character = Player.Character or Player.CharacterAdded:wait()
local Humanoid = Character:waitForChild("Humanoid")
local Animation = workspace:waitForChild("Animation")
local AnimationTrack = Humanoid:LoadAnimation(Animation)
local UIS = game:getService("UserInputService")
UIS.InputBegan:connect(function(InputObject, gameProcessedEvent)
if not gameProcessedEvent then
if InputObject.KeyCode == Enum.KeyCode.P then
AnimationTrack:Play()
end
end
end)

2 comments
Try to redirect your animation as the child of your script. Also, add "print" functions a line after every "WaitForChild" methods and make sure that they're printed in the output. If one line isn't printed, then that means the object before that line is nonexistent.
^ As mentioned above, put print functions on every line to see where the script is stopping. It may be a little obnoxious at first, but you'll find the problem.