I'm trying to modify the "Adventure Island" gear to submit score, but I'm having a little trouble with the function, what happens is it puts my name on all of the leaderboard spots instead of just the one of which that I beat (#1 lol). Here is the code...
function SubmitScore() prevn1 = va.Names.one.Value prevn2 = va.Names.two.Value prevn3 = va.Names.three.Value prevn4 = va.Names.four.Value prevn5 = va.Names.five.Value prevn6 = va.Names.six.Value prevn7 = va.Names.seven.Value prevs1 = va.Points.one.Value prevs2 = va.Points.two.Value prevs3 = va.Points.three.Value prevs4 = va.Points.four.Value prevs5 = va.Points.five.Value prevs6 = va.Points.six.Value prevs7 = va.Points.seven.Value if gameData.Score > va.Points.one.Value then va.Points.one.Value = score --pretty much just continues this va.Names.one.Value = game.Players.LocalPlayer.Name --on every line va.Points.two.Value = prevs1 --and va.Names.two.Value = prevn1 --this va.Points.three.Value = prevs2 va.Names.three.Value = prevn2 va.Points.four.Value = prevs3 va.Names.four.Value = prevn3 va.Points.five.Value = prevs4 va.Names.five.Value = prevn4 va.Points.six.Value = prevs5 va.Names.six.Value = prevn5 va.Points.seven.Value = prevs6 va.Names.seven.Value = prevn6 va.Points.eight.Value = prevs7 va.Names.eight.Value = prevn7 return elseif gameData.Score > va.Points.two.Value then va.Points.two.Value = score va.Names.two.Value = game.Players.LocalPlayer.Name va.Points.three.Value = prevs2 va.Names.three.Value = prevn2 va.Points.four.Value = prevs3 va.Names.four.Value = prevn3 va.Points.five.Value = prevs4 va.Names.five.Value = prevn4 va.Points.six.Value = prevs5 va.Names.six.Value = prevn5 va.Points.seven.Value = prevs6 va.Names.seven.Value = prevn6 va.Points.eight.Value = prevs7 va.Names.eight.Value = prevn7 return elseif gameData.Score > va.Points.three.Value then va.Points.three.Value = score va.Names.three.Value = game.Players.LocalPlayer.Name va.Points.four.Value = prevs3 va.Names.four.Value = prevn3 va.Points.five.Value = prevs4 va.Names.five.Value = prevn4 va.Points.six.Value = prevs5 va.Names.six.Value = prevn5 va.Points.seven.Value = prevs6 va.Names.seven.Value = prevn6 va.Points.eight.Value = prevs7 va.Names.eight.Value = prevn7 return elseif gameData.Score > va.Points.four.Value then va.Points.four.Value = score va.Names.four.Value = game.Players.LocalPlayer.Name va.Points.five.Value = prevs4 va.Names.five.Value = prevn4 va.Points.six.Value = prevs5 va.Names.six.Value = prevn5 va.Points.seven.Value = prevs6 va.Names.seven.Value = prevn6 va.Points.eight.Value = prevs7 va.Names.eight.Value = prevn7 return elseif gameData.Score > va.Points.five.Value then va.Points.five.Value = score va.Names.five.Value = game.Players.LocalPlayer.Name va.Points.six.Value = prevs5 va.Names.six.Value = prevn5 va.Points.seven.Value = prevs6 va.Names.seven.Value = prevn6 va.Points.eight.Value = prevs7 va.Names.eight.Value = prevn7 return elseif gameData.Score > va.Points.six.Value then va.Points.six.Value = score va.Names.six.Value = game.Players.LocalPlayer.Name va.Points.seven.Value = prevs6 va.Names.seven.Value = prevn6 va.Points.eight.Value = prevs7 va.Names.eight.Value = prevn7 return elseif gameData.Score > va.Points.seven.Value then va.Points.seven.Value = score va.Names.seven.Value = game.Players.LocalPlayer.Name va.Points.eight.Value = prevs7 va.Names.eight.Value = prevn7 return elseif gameData.Score > va.Points.eight.Value then va.Points.eight.Value = score va.Names.eight.Value = game.Players.LocalPlayer.Name return end end
function SubmitScore(newName, newScore) local prevn1 = va.Names.one.Value local prevn2 = va.Names.two.Value local prevn3 = va.Names.three.Value local prevn4 = va.Names.four.Value local prevn5 = va.Names.five.Value local prevn6 = va.Names.six.Value local prevn7 = va.Names.seven.Value local prevs1 = va.Points.one.Value local prevs2 = va.Points.two.Value local prevs3 = va.Points.three.Value local prevs4 = va.Points.four.Value local prevs5 = va.Points.five.Value local prevs6 = va.Points.six.Value local prevs7 = va.Points.seven.Value local prevNames = {prevn1, prevn2, prevn3, prevn4, prevn5, prevn6, prevn7} local prevScores = {prevs1, prevs2, prevs3, prevs4, prevs5, prevs6, prevs7} for i,v in pairs(prevScores) do if newScore > prevScores[i] then if newScore > prevScores[i+1] then else for k, prevScores[i] in pairs(prevScores) do --corrected if db then if newScore > prevScores[k] then prevScores[k] = prevScores[k+1] prevNames[k] = prevNames[k+1] else prevScores[k-1] = newScore prevNames[k-1] = newName end end if prevScores[k-1] == newScore then break end end end end end end
I have absolutely no way of testing this, so I hope it works. Feel free to play around with the script and ask questions. Don't forget to accept the answer and/or upvote if you found this helpful. Thanks!