I have this function that chooses the biggest Value from a set of "NumberValues", but how can I make it so if the two biggest numbers are the same, the script chooses a value from the two randomly?
function Greatest(child)
local number, map = 0, nil
local Vote1 = game:GetService("ReplicatedStorage"):WaitForChild("MapVote1")
local Vote2 = game:GetService("ReplicatedStorage"):WaitForChild("MapVote2")
local Vote3 = game:GetService("ReplicatedStorage"):WaitForChild("MapVote3")
for _, v in pairs(child) do
if v:IsA("NumberValue") and v.Value > number then
number = v.Value
map = v
end
end
return number, map
end

3 comments
It may be a bit tedious but you can put them in a table, set a variable to math.random(1,#tablelength) and have it index the map chosen
table.sort and array :p
@Mr_Pure, can you show me an example? You can do it with just plain numbers or anything you feel comfortable with.