Help with getting most valuable variable

so i dont know what to do

local votes = {
	TestMapVotes = 1,
	TowerMapVotes = 12
}

local highest = math.max(unpack(votes))
		print(highest)

I don’t think you can unpack a dictionary like this.

1 Like

Try this:

local votes = {
	TestMapVotes = 1,
	TowerMapVotes = 12
}

local function GetHighestValue(dictionary)
	local highestValue = 0
	
	for valueName, value in pairs(dictionary) do
		if value > highestValue then
			highestValue = value
		end
	end
	
	return highestValue
end

print(GetHighestValue(votes))
2 Likes

how can I do if TowerMapVotes is the highest then or if TestMapVotes then?
nvm got it