I Need Help On creating A script, I'm not sure how'd you do this. There is a Folder. Here is the Format
Script.Players(Folder).Player(NumValue)
Player Is Set Up as Name = Player Name And Value = Value
So What I am trying to say is something like this,
for i=1,HowManyDoIFind.Value do Find Highest Value Return The Value And The Name Insert Name And Values In Order On Table Named "Scores" end
And Whenever I Need The 1st Winner Or 5th Winner, I just Access The Table. Problem Is I Don't Know How to make the script.
The simplest way to accomplish this would be sort the list of Player NumberValues.
To sort, you need a list:
local scores = script.Players:GetChildren()
and a way to compare two things (a function). This function is supposed to return true
if first
should be ranked before second
:
function compare(first, second) return first.Value > second.Value end
Now you just call table.sort
using scores
and compare
:
table.sort(scores, compare)
and then scores[1]
is the highest scoring player, up to scores[#scores]
:
for i = 1, #scores do print(i .. "st", scores[i].Name, "scored", scores[i].Value, "points") end