Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How To Insert All Players In Tables?

Asked by
GentiRob -81
5 years ago

So When Game Starts, Players all teleport To Game Place, I want to do a sword game, So When someone of players die, They all teleport to their own podium and starting again until last man standing, help pls!

0
give it a go LawlR 182 — 5y
0
I Don't Even Know How To Start GentiRob -81 — 5y

2 answers

Log in to vote
0
Answered by 5 years ago
Edited 5 years ago

That's fairly easy.

local playerservice = game:service'Players'
local players = {} --// let's create a table to store the players in

function get_players()
    players = {} --// clears the table

    for _, a in pairs(playerservice:players()) do --// gets all the players
        table.insert(players, a.Name) --// inserts them to the table
    end
end 

Now, when you want to get the players and store them inside the table just do:

get_players()

This should work and if it does help you, accept my answer. Thanks :)

Ad
Log in to vote
-2
Answered by
Sorukan 240 Moderation Voter
5 years ago
Edited 5 years ago
local Players = game.Players:GetPlayers()

This will create a table of all the players currently in the game and you can do whatever you want with them.

0
uh no.. that will just get the service lol User#23365 30 — 5y
1
Whoops Sorukan 240 — 5y

Answer this question