So I currently have this code here:
if bestMatchId == nil then
local NewMatch = { Players = {}, MapId = map, updateFunc = function(match, matchPos)
print("Firing update func with id", matchPos)
MatchmakingService:FireAllClientsEvent(UPDATE_MATCH_DETAILS_EVENT, matchPos, match.MapId)
if #match.Players >= 1 then
wait(5)
local TS = game:GetService("TeleportService")
local CodeSuccess
local TSCode
local Attempt = 0
repeat Attempt = Attempt + 1 CodeSuccess, TSCode = pcall(function() TS:ReserveServer(PlaceIds[map]) end) until CodeSuccess == true or Attempt > 5
-- Teleport players
local TPSuccess, TpMessage
local TpAttempt = 0
repeat TpAttempt = TpAttempt + 1 TPSuccess, TpMessage = pcall(function() TS:TeleportToPrivateServer(PlaceIds[map], TSCode, match.Players, "Start", {}) end) if TPSuccess == false then warn("TP ERROR:", TpMessage) end until TPSuccess == true or TpAttempt > 5
Matches[matchPos] = nil
end
end }
table.insert(NewMatch.Players, player)
local pos = table.getn(Matches[map]) + 1
table.insert(Matches[map], pos, NewMatch)
bestMatchId = pos
print("Firing update func with pos", pos)
NewMatch:updateFunc(NewMatch, pos)
end
It pretty much makes a new dictionary that represents a match, and it has a update function that is called each time the match is updated. When the match is initially created, it's inserted into the main table with all matches, and then prints "firing update func with pos insert pos in main table here", but in the update function itself when I run print("Firing update func with id", matchPos) it prints out that the matchPos part is a table, leading me to believe at some point Roblox is converting my number to a table somehow.

7 comments
What does the code you're using to call the function look like? Try printing 'match' as well. Figure out the contents of both arguments.
The NewMatch is the table that's being created with the function inside it. The function runs each time I make a change to the table (such as adding a player) with the params match and matchPos. So match is the table with the function being called inside.
After doing a bit more debugging, I printed out matchPos and match with inspect, and it appears that matchPos went from being a number as intended to being the exact same table as argument #1.
This is very useful for debugging, I feel like a lot of people don't use it: https://blog.roblox.com/2017/11/lua-debugger-enhancements/
Oh thanks!! I didn't know that existed!
I used the debugger you mentioned, but it only showed what I noticed in comment number 3. the matchPos argument that I passed into the function at line 24 was a number as proven by line 23, but at line 3 it's clearly changed to a table somehow, and the debugger shows that its the exact same table as argument #1. So somehow argument #2 was set to equal argument 1. My only idea on how to solve this
is to put the update function outside of the match table.