I am trying to make a system that compares values of votes and decides which map has the highest vote and then load the map. Although, I cannot figure out how to compare all 3 maps at the same time. I have already looked everywhere but I cannot find a topic that covers this. Any ideas on how I can accomplish this?
You could just use some simple if statements.
local map1Votes = 15
local map2Votes = 37
local map3Votes = 3
if map1Votes > map2Votes and map1Votes > map3Votes then
-- load map1 as it has the most votes
elseif map2Votes > map1Votes and map2Votes > map3Votes then
-- load map2
else
-- load map3
end
Does not work workspace.Script:175: attempt to compare two table values
I don’t know if I did something wrong
Just realized I need to convert table to integers
How are you holding the number of votes? If it’s in a table per map, you’ll have to use the length of the table
local table = {1,2,5,6,3}
local tableLength = #table -- = 5 (5 elements in the table)
2 Likes