I’m trying to make a function that will play an animation when you press the F key. However, I keep getting an error that says "attempt to index nil with ‘WaitForChild’ " on line 5. This is all done in a LocalScript in StarterPlayerScripts. Any help is appreciated.
local uis = game:GetService("UserInputService")
local player = game.Players.LocalPlayer
local char = player.Character
local humanoid = char:WaitForChild("Humanoid")
local anim = script:FindFirstChild("Animation")
local playanim = humanoid:LoadAnimation(anim)
uis.InputBegan:Connect(function(input)
if input.KeyCode == Enum.KeyCode.F then
playanim:Play()
end
end)