I was creating a racing game and it loads the player into a metatable, but it’s not going in the table.
playersInRaces[player.UserId] = id
local playermeta = {
__newindex = function (playersInRace, playerid, raceid)
local Proccessor = RaceProccessor:GetLocal(raceid)
local leftConnection = Proccessor.PlayerLeft:Connect(function (playerleftid)
if playerleftid == playerid then
rawset(playersInRace, playerid, nil)
end
end)
Proccessor.Reset:Once(function ()
leftConnection:Disconnect()
rawset(playersInRace, playerid, nil)
end)
end
}
local playersInRaces = {}
setmetatable(playersInRaces, playermeta)
The first is how I added it to the table, the second is the metatable.
When I print the table, even right after I added it, the table is empty.
Any help is appreciated!