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

How could you make a variable for this?

Asked by 9 years ago

I just want a variable that defines all players

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

0
Making the `pairs` function a variable would cast an error, In other words it will not work. woodengop 1134 — 9y

2 answers

Log in to vote
1
Answered by
ImageLabel 1541 Moderation Voter
9 years ago

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()
Ad
Log in to vote
1
Answered by
Relatch 550 Moderation Voter
9 years ago

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

Answer this question