I'm attempting to recreate chess and I have a function which adds an object value in every adjacent part for the king (Which I calculate from the part's name which has coordinate data)
However when the king is at the edge of the board my code checks for a part which doesn't exist, and so I use findFirstChild instead. I expected this to set the parent for the clone of my object value to nil, and thus not put it anywhere but instead it returns an error;
attempt to index a nil value
CODE:
clone = pieceValue:clone() clone.Parent = workspace:FindFirstChild(n - 1 .. l + 1).CoveredBy
What is a way of ignoring parts which don't exist or will I have to use an if statement for every part check I do?

1 comment
It's probably trying to do
nil.CoveredBywhich throws an error