#does anyone know a faster and better way to write this script

1 messages · Page 1 of 1 (latest)

kind mantle
#

does anyone know a faster and better way to write this script for example if there are more colors, so that I don't have to keep writing a thousand colors in each column

if scores.Red >= scores.Blue and scores.Red >= scores.Yellow and scores.Red >= scores.Green and scores.Red >= scores.Orange then
redwinner.Text = "Winning!"
else
redwinner.Text = " "
end

if scores.Blue >= scores.Red and scores.Blue >= scores.Yellow and scores.Blue >= scores.Green and scores.Blue >= scores.Orange then
    bluewinner.Text = "Winning!"
else
    bluewinner.Text = " "
end

if scores.Yellow >= scores.Blue and scores.Yellow >= scores.Red and scores.Yellow >= scores.Green and scores.Yellow >= scores.Orange then
    yellowwinner.Text = "Winning!"
else
    yellowwinner.Text = " "
end

if scores.Green >= scores.Blue and scores.Green >= scores.Yellow and scores.Green >= scores.Red and scores.Green >= scores.Orange then
    greenwinner.Text = "Winning!"
else
    greenwinner.Text = " "
end

if scores.Orange >= scores.Blue and scores.Orange >= scores.Yellow and scores.Orange >= scores.Green and scores.Orange >= scores.Red then
    orangewinner.Text = "Winning!"
else
    orangewinner.Text = " "
end
dapper pasture
#

for that you can use a for loop to get the max score

#

and record which key the score belongs to

#

local maxkey,maxvalue=nil,0 for key,val in scores do if val>maxvalue then maxkey,maxvalue=key,val end end

#

pretty easy

kind mantle