This is probably a simple answer, but I'm not sure how to do this.
I need to get a table of players, but only add them if they have a certain leaderstat value.
For example,
if player.leaderstats.Wins.Value > 0 then
--add to table
end
Thanks!
This is probably a simple answer, but I'm not sure how to do this.
I need to get a table of players, but only add them if they have a certain leaderstat value.
For example,
if player.leaderstats.Wins.Value > 0 then
--add to table
end
Thanks!
Create a blank table, and then use Players:GetPlayers() to get the players. and then use the function table.insert in order to insert the table.
local playerTab = {} --Blank for now.
local players = game.Players:GetPlayers()
for i, v in pairs(players) do
if v.leaderstats.Win.Value > 0 then
table.insert(players, 1, v.Name) --It'll insert itself first in the list, if you don't want it to do that, then change the number.
end
end
So that's the basic thing. It'll insert player's names inside the specific table. However, I suggest doing it in alphabetical order. So that you can get the precise names.
This discussion is preserved as it was. New answers, comments, and votes are closed.
1 comment
Thank you!!