Matchmaking: Attempt to index nil with number

Why does it give me this error even though I am just looping correctly over all players:

ServerScriptService.MatchmakingHandler:11: attempt to index nil with number

It’s about this line:

if player.UserId == tab[1] or player.UserId == tab[2] then

I am trying to loop over servers and find the players that requested the match and grab those player objects and let them teleport, I couldn’t pass in the player object through an request unfortunately.

local HttpService = game:GetService("HttpService")
local TeleportService = game:GetService("TeleportService")
local proximityPrompt = workspace["Button Stand"].Button.ProximityPrompt
local MessagingService = game:GetService("MessagingService")
local Players = game:GetService("Players")

MessagingService:SubscribeAsync("JoinPrivateServer", function(data)
	local tab = data.sendData
	
	for i, player in pairs(Players:GetPlayers()) do
		if player.UserId == tab[1] or player.UserId == tab[2] then
			TeleportService:TeleportToPrivateServer(xx, tab[3], {player})
		end
	end
end)

local function request(p)
	print('Player ID: ' .. p)
	local response = HttpService:RequestAsync(
		{
			Url = "http://xx.xxx.xxx.xx:xxxx/mm",  -- Host server that handles matchmaking
			Method = "POST",
			Headers = {
				["Content-Type"] = "application/json",
				["key"] = "xxxx="  -- Api key to validate the request
			},
			Body = HttpService:JSONEncode({player = p})
		}
	)

	-- Inspect the response table
	if response.Success then
		if response.Body ~= "wait for players" then
			print('Matching up!')
			local content = HttpService:JSONDecode(response.Body)
			local sendData = {}
			for i, v in pairs(content) do
				print(v)
				table.insert(sendData, v)
			end
			local code = TeleportService:ReserveServer(xx)
			table.insert(sendData, code)
			
			for i, v in pairs(sendData) do
				print(v)
			end
			
			wait()
			MessagingService:PublishAsync("JoinPrivateServer", sendData)
		end
	end
end

proximityPrompt.Triggered:Connect(function(plr)
	print('triggered')
	local success, errormsg = pcall(request, plr.UserId)

	if not success then
		print("An error occured!:")
		warn(errormsg)
	end
end)

Probably Cause There Is Nothing Such As

		if player.UserId == tab[1] or player.UserId == tab[2] then

Thats Why It Gives Error

oh wow i’m not that bright today i just had to pass in data instead of data.sendData
thanks anyways though.

oh fantastic to allow other people not to help anymore just accept my answer as a solution