So I made a script which decides what’s the map with the highest votes.
However, it’s not optimized, and it has some issues.
So I wanna know I can improve the way I did it.
My current code
local chosenMap
if blocksVotes.Value > cityVotes.Value and blocksVotes.Value > forestVotes.Value and blocksVotes.Value > skylandsVotes.Value then
chosenMap.Value = blocksVotes.Parent.Name
end
if cityVotes.Value > blocksVotes.Value and cityVotes.Value > forestVotes.Value and cityVotes.Value > skylandsVotes.Value then
chosenMap.Value = cityVotes.Parent.Name
end
if forestVotes.Value > cityVotes.Value and forestVotes.Value > blocksVotes.Value and forestVotes.Value > skylandsVotes.Value then
chosenMap.Value = forestVotes.Parent.Name
end
if skylandsVotes.Value > forestVotes.Value and skylandsVotes.Value > cityVotes.Value and skylandsVotes.Value > blocksVotes.Value then
chosenMap.Value = skylandsVotes.Parent.Name
end
function PickHigh(fv1)
local High = 1
for i, v in pairs(fv1) do
if v > fv1[High] then
High = i
end
end
return fv1[High]
end
chosenMap.Value = PickHigh({blocksVotes.Value, cityVotes.Value, forestVotes.Value, skylandsVotes.Value}).Parent.Name
function PickHigh(fv1)
local High = 1
for i, v in pairs(fv1) do
if v.Value > fv1[High] then
High = i
end
end
return fv1[High]
end
chosenMap.Value = PickHigh({blocksVotes, cityVotes, forestVotes, skylandsVotes}).Parent.Name
function PickHigh(fv1)
local High = 1
for i, v in pairs(fv1) do
if v.Value > fv1[High].Value then
High = i
end
end
return fv1[High]
end
chosenMap.Value = PickHigh({blocksVotes, cityVotes, forestVotes, skylandsVotes}).Parent.Name