Code is inside a module which is server sided only and it has 2 functions which should work together to pick a map. One gets all the votes and the other sets the map. The issue is that when I call the function to get the votes it returns an empty table even tho when I check the table before returning it has content inside it. Here’s the code:
local function GetVotes(voting)
local votes = {}
for _, player in pairs(GAME.Players) do
local voted = player.Matchmaking['Voted'..voting]
if voted then
if not votes[voted] then
votes[voted] = 0
end
votes[voted] += 1
end
end print(votes) -- this actually prints a table with content
return votes
end
local function SelectMostVoted(voting, storage)
local votedList = GetVotes(voting) print(votedList)-- this prints out an empty table
end
Solved it, the issue was [‘Voted’…voting] part, basically I used GetVotes() function on 2 different occasions (one I didn’t show because I completely forgot about it) and one was sending ‘Map’ and the other was sending ‘VotedMap’ and because of that one of them didn’t work due to such index not existing inside the table. I fixed it by removing ‘Voted’ from the function and adding it to the GetVotes() call.