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

Is it possible to detect how many players are in a game? [closed]

Asked by 3 years ago

I'm quite curious about this question, and I'd like to know. I'd like to make a TextLabel, and add a script that changes the text whenever one joins or leaves a game.

Closed as Not Constructive by WideSteal321, Cynical_Innovation, IAmNotTheReal_MePipe, matiss112233, and raid6n

This question has been closed because it is not constructive to others or the asker. Most commonly, questions that are requests with no attempt from the asker to solve their problem will fall into this category.

Why was this question closed?

2 answers

Log in to vote
0
Answered by 3 years ago

Please provide explanation with your answers. Simply posting code does not spread knowledge of integral scripting processes which helps people understand the logic and reasoning behind your answer.

Simple line:

while wait(60) do
local players = game.Players:GetChildren()
print("There are "..#players.." players in the game!")
end

This will just say how many players there are every minute

0
(Simple lines) JB_SuperGamer 165 — 3y
Ad
Log in to vote
-1
Answered by 3 years ago
Edited 3 years ago

Please provide explanation with your answers. Simply posting code does not spread knowledge of integral scripting processes which helps people understand the logic and reasoning behind your answer.

Very simple. Do this in the dev console

print(#game:GetService("Players"):GetPlayers())

or

print(#game:GetService("Players"):GetChildren())