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.
I solved my issue my putting the update function outside of the table. For some reason, Lua seems to change the argument #2 to be the exact same as #1 in the function.
EDIT: I'm just looking back at this question, and now I see why what happened did. When calling the update function, I was using :
so the first argument is itself.