Issue with math.max()

Hi, I’m attempting to make a voting system ( has gone good so far ), for some reason its picking a map other than the one that’s highest any help with be appreciated!

function intermission.PickWinningVote()
	local highestnumber = 0
	local temp_table = {}
	local game_folder = game:GetService("ServerStorage"):WaitForChild("Games")
	
	for i = 1, 3 do
		local map = intermission.mapChoices[i].Votes

		print(map.Value)
		
		table.insert(temp_table, map.Value)
		
	end
	
	for index, value in pairs(temp_table) do
		warn(value)
		highestnumber = math.max(unpack(temp_table))
	end
	
	print(highestnumber)
	
	print(intermission.mapChoices[highestnumber].Name)
	--game_module.CloneMap(intermission.mapChoices[highestnumber].Name)
end

No errors

I think the issue may be that you need to get the index of the highest voted place

local highestVoted = table.find(temp_table,highestnumber)
print(intermission.mapChoices[highestVoted].Name)

math.max just returns the highest number given

Okay one second going to test this out :slight_smile:

Works thank you so much! :smiley:

1 Like

Anytime! If you have anymore issues don’t be afraid to make another post!

1 Like

Will do thanks, once again thank you :smile:

1 Like