I have 4 possible maps for players to vote from before a game and I have no idea how to detect which map has the most votes. I already have a system for counting map votes, I just don’t know how to find the most voted map.
1 Like
Its like doing this:
local votes = {[10] = "Tree", [25] = "Wood", [26] = "Bark"}
--the index (the numbers) are the votes in this case
-- the value in this case is the "map"
local currentAmount = 0 -- so we can store the Highest Amount of Votes for a Map
for votes,_ in votes do -- iterates through the Table
if currentAmount <= votes then -- if the Current Amount is less than the one were looking at currently
currentAmount = votes -- sets a new limit for the Votes to pass
end
end
-- The index with the highest number will be chosen
print(votes[currentAmount] .. " got the Most Votes!")
1 Like
Wouldn’t it be more preferable if you used the map name as the index and the number of votes as the value in the table?
you can flip it, doesnt affect the code.
thanks bro it works
also thanks for actually explaining the code
1 Like
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.