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

How could you make a variable for this?

I just want a variable that defines all players

local e = for _,v in pairs(game.Players:GetPlayers()) do --this does not work

1 comment

0

Making the pairs function a variable would cast an error, In other words it will not work.

2 answers

You simply need to use the GetPlayer function of Players, which returns a table/list of all descendants of Players that are player objects. All you'd have to do then is assign a variable to the function.

players = game:GetService("Players"):GetPlayers()

Not sure what you mean by a variable that defines all players, but I'm pretty sure this will work, if you want to just get all players.

local players = game:GetService("Players"):GetPlayers()

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