Attempt to index nil with 'FindFirstChild'?

Hello Developers!
I’m making a board game, in my game. But my problem is, it said attempt to index nil with 'FindFirstChild'. I put a comment in the line script -- Error is here so you would know where it is. Thanks for the help!
My script:

local EastIsAvailable = false
		local WestIsAvailable = false
		local NorthIsAvailable = false
		if player.Name == script.Parent.PlayerUser.Value the
			for _, f in pairs(Board.Parent.Checks:GetChildren()) do
				for _, s in pairs(f:GetChildren()) do
					if s.Value == Board.Name.."Spy2" then
						local s_ToInteger = tonumber(script.Parent.StringToNumber:FindFirstChild(s.Name).Value)
						local CheckEast = s_ToInteger + 1
						local CheckWest = s_ToInteger - 1
						local North = table.find(alphabet, string.lower(f.Name))
						print("North prev int: "..North)
						local _North = North - 1
						print("North next int: ".._North)
						local CheckNorth = alphabet[_North]
						print("East int: "..CheckEast)
						print("West int: "..CheckWest)
						print("North letter: "..CheckNorth)
						delay(0.1, function()
							if Board.Parent.Checks:FindFirstChild(CheckNorth):FindFirstChild(s.Name) ~= "" then -- Error Here
								NorthIsAvailable = true
							else
								NorthIsAvailable = false
							end
							if Board.Parent.Checks:FindFirstChild(f.Name):FindFirstChild(CheckEast).Value ~= "" then -- Maybe also here?
								EastIsAvailable = true
							else
								EastIsAvailable = false
							end
							if Board.Parent.Checks:FindFirstChild(f.Name):FindFirstChild(CheckWest).Value ~= "" then -- and here??
								WestIsAvailable = true
							else
								WestIsAvailable = false
							end
						end)

					end
				end
			end

This problem is most likely, because there isn’t a variable ‘CheckNorth’ or it doesn’t exist in Board.Parent.Checks. If the name of the needed object is ‘CheckNorth’ try it like this:

Board.Parent.Checks:FindFirstChild('CheckNorth'):FindFirstChild(s.Name)

If this doesn’t work, then check the path of your variable.

1 Like

the Checks has no child that named “CheckNorth”. and the CheckNorth Variable is only there to check the string(letter) in the table(not a path).
image

I’m guessing the alphabet table contains just strings of each letter. Is it possible that one letter doesn’t exist in the alphabet table?

on my alphabet table. I only put the letter A-H

I think I know the issue now. If you keep counting _North down, eventually it will be 0. So CheckNorth will be nil, since 0 isn’t a index of the table. Try adding this line, before the delay function:

if CheckNorth == nil then return end

am i supposed to make it

if CheckNorth == nil then
return
-- My code here where CheckNorth is
end

Or

if CheckNorth == nil then return end
-- My  code here where CheckNorth is

Cause both didn’t work

local EastIsAvailable = false
local WestIsAvailable = false
local NorthIsAvailable = false

if player.Name == script.Parent.PlayerUser.Value then
	for _, f in pairs(Board.Parent.Checks:GetChildren()) do
		for _, s in pairs(f:GetChildren()) do
			if s.Value == Board.Name.."Spy2" then
				local s_ToInteger = tonumber(script.Parent.StringToNumber:FindFirstChild(s.Name).Value)
				local CheckEast = s_ToInteger + 1
				local CheckWest = s_ToInteger - 1
				local North = table.find(alphabet, string.lower(f.Name))
				print("North prev int: "..North)
				local _North = North - 1
				print("North next int: ".._North)
				local CheckNorth = alphabet[_North]
				print("East int: "..CheckEast)
				print("West int: "..CheckWest)
				print("North letter: "..CheckNorth)
				delay(0.1, function()
					if Board.Parent.Checks:FindFirstChild(CheckNorth):FindFirstChild(s.Name) ~= "" then -- Error Here
						NorthIsAvailable = true
					else
						NorthIsAvailable = false
					end
					if Board.Parent.Checks:FindFirstChild(f.Name):FindFirstChild(CheckEast).Value ~= "" then -- Maybe also here?
						EastIsAvailable = true
					else
						EastIsAvailable = false
					end
					if Board.Parent.Checks:FindFirstChild(f.Name):FindFirstChild(CheckWest).Value ~= "" then -- and here??
						WestIsAvailable = true
					else
						WestIsAvailable = false
					end
				end)
			end
		end
	end
end
if player.Name == script.Parent.PlayerUser.Value the

Missing “n” at end, also missing an end statement at the end of the script.

“Board.Parent.Checks” this however must be nil, so make sure the references are correct.