Table items becoming nil when attemping to reference them

This is probably just a dumb small bug, because I took like a 3 month break from scripting, but I’m working on a queueing system for my 1v1 fighting game, and whenever the queue is filled, it fires a createRound() function with the parameters “people” (the table), “Map”, and “queuePart”.

The issue is that, when I try to make variables for each of the 2 players referencing the people table, everything comes out as nil. I’ve checked to see if the table parameter was nil through a print and yeah, it’s still very much there, its just that the items in the table want to peace out the second they get referenced?

Here’s my horrible code:

Queue (In the QueuePart):

local PS = game:GetService("Players")
local RS = game:GetService("ReplicatedStorage")

local Remotes = RS:WaitForChild("Remotes")
local CreateRoundEvent = Remotes:WaitForChild("CreateRound")

local part = script.Parent
local attachment = script.Parent:WaitForChild("Attachment")
local queuedPlayers = {}

local Map = "TestMap"

part.Touched:Connect(function(hit)
	if hit.Parent:FindFirstChild("Humanoid") then
		if #queuedPlayers <= 1 and not table.find(queuedPlayers, tostring(hit.Parent)) then
			print("added")
			local character = hit.Parent
			table.insert(queuedPlayers, character.Name)
			print(queuedPlayers)
			
			if #queuedPlayers == 2 then
				print("start")
				CreateRoundEvent:Fire(queuedPlayers, Map, part)
			end
		end
	end
end)

RoundCreator (SSS, also THIS is the one that has the issue, probably should have put this one first):

local PS = game:GetService("Players")
local RS = game:GetService("ReplicatedStorage")

local Remotes = RS:WaitForChild("Remotes")
local Maps = RS:WaitForChild("Maps")
local CreateRoundEvent = Remotes:WaitForChild("CreateRound")

CreateRoundEvent.Event:Connect(function(people, map, queuePart)
	print(people) -- perfectly fine
	print(table.find(people, 1)) -- returns "nil" even tho on the literal last line it said they were there...?
	
	local Player1 = PS:WaitForChild(tostring(table.find(people, 1)))
	local Player2 = PS:WaitForChild(tostring(table.find(people, 2)))
	
	local selectedMap = Maps:WaitForChild(tostring(map)):Clone()
	local attachment = queuePart:WaitForChild("Attachment")
	
	selectedMap.PrimaryPart.CFrame = attachment.WorldCFrame
	selectedMap.Parent = workspace.CurrentMaps
	
	local tele1 = selectedMap:WaitForChild("Tele1")
	Player1:MoveTo(tele1.CFrame)
	local tele2 = selectedMap:WaitForChild("Tele2")
	Player2:MoveTo(tele2.CFrame)
end)

Any and all help is greatly appreciated!!! Also, mind me if i’m slow to respond, as right after I post this, I’m going to have a delightful mimir with many z’s.

In the CreateRoundEvent Connection, replace all occurrences of table.find(people, Index) with people[Index].

table.find is used to get the indices of values instead of the values of indices

Instead you want to just normally index the table using this syntax: Table[Index]

The reason why it was returning nil was because it was searching for a value of 1 and 2 within the table which don’t exist