So, I researched about this script that allows a character to press a key (F in this case) and a animation would be played. I tried to use the script but it wouldnt work. How would I go about fixing it?
local player = game:GetService("Players").LocalPlayer
local character = player.Character or player.Character:Added()
local humanoid = character:WaitForChild("Humanoid")
local anim = Instance.new("Animation")
anim.AnimationId = "rbxassetid://511512134"
function playAnimation(Anim)
local track = humanoid:LoadAnimation(Anim)
track:Play()
end
game:GetService("UserInputService").InputBegan:connect(function(input ,proc)
if not proc then
if input.KeyCode == Enum.KeyCode.F then
playAnimation(anim)
end
end
end)

2 comments
You capitalized the 'A' in "anim" when you loaded the animation inside of the function. That's one of your errors I just found.
That is not the problem here as he passes the animation on line 13, though he does not need to do this.