Attempt to index Nil with FindFirstChild

Hello, I’m currently working on my own gun system for my group and I cant figure out how to fix this error,
I’ve looked it up on DevForum but I can’t find an answer that works.

Here’s my code:

local player = game.Players.LocalPlayer

local character = player.Character
local humanoid = character:FindFirstChild("Humanoid")
local animation = script.Parent.Idle
local animtrack = humanoid:LoadAnimation(animation)

local function equip()

local function unequip()


I hope someone responds soon, thanks.


Where is the FindFirstChild exactly? I can’t see it in your code.

You have to wait until the Character is loaded in to proceed. Use this: character = player.Character or player.CharacterAdded:wait()

Are you sure you pasted the right script? I don’t see FindFirstChild anywhere in the script?

Fixed it, its in the humanoid variable.

im getting this now…

Use character:WaitForChild("Humanoid") instead of character:FindFirstChild("Humanoid"). Again: you’re waiting until everything loads in.

1 Like