I am working on a round based game and am storing player “states” in tables. I am able to insert players into the table with the AddPlayerToTable function but when it looks for the player in the table it is unable to find it. Returning nil(given the Playing table the function should return true).
I’m not really sure why this is the case, my best guess is when I add the player to the table (using val) it is creating a separate table to place the player in instead of the one defined in Tables.
Any help on this issue is appreciated.
Tables
local Tables = {
Playing = {},
CurrentPlayers = {},
DeadPlayers = {}
}
Function for adding players to the table
–val = Playing
function module:AddPlayerToTable(player,val)–val is the table to edit
if Tables[val] then
if not Tables[val][player] then
table.insert(Tables[val],player)
end
end
end
Function for finding if player is in the table
–val = Playing
function module:PlayerIsInTable(player,val)
if Tables[val] then
if Tables[val][player] then
return true
end
end
print(‘not in table’)
return nil
end