I am having a error with table.find

Hello, I am trying to check if a player touched this part and if they did it, then it checks if the player is already inside the table and if not then it adds them to the table

it works but its also giving me a error, I also commented on the line that it errors

Screenshot (591)

how would I fix this?

PlayerChecker.Touched:Connect(function(hit)

		local Humanoid = hit.Parent:FindFirstChild("Humanoid")

		if table.find(PlayerTable, Humanoid.Parent.Name) then -- THIS LINE ERRORS
			
		else
			
			table.insert(PlayerTable, Humanoid.Parent.Name)
		end
			
	end)

Your code assumes a humanoid was found. In this case, none was found.

Add an extra thing to check for in your if statement like so.

PlayerChecker.Touched:Connect(function(hit)

		local Humanoid = hit.Parent:FindFirstChild("Humanoid")

		if Humanoid ~= nil and table.find(PlayerTable, Humanoid.Parent.Name) then -- Check for nil
			
		elseif Humanoid ~= nil then -- And here
			
			table.insert(PlayerTable, Humanoid.Parent.Name)
		end
			
	end)

wow thanks, that error is gone