Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How To Insert All Players In Tables?

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!

2 comments

0

give it a go

0

I Don't Even Know How To Start

2 answers

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 :)

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.

2 comments

0

uh no.. that will just get the service lol

1

Whoops

This discussion is preserved as it was. New answers, comments, and votes are closed.