generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripters
Home Search
 

Re: Check for number of players?

Previous Thread :: Next Thread 
Isometricity is not online. Isometricity
Joined: 26 Oct 2011
Total Posts: 438
02 Jul 2012 03:54 PM
How do I check for a certain number number of players in a game?

Also on a side note, how do I prevent any new players from entering a server after that number is reached, so a server is locked from new players once the server is full, but doesn't ever unlock?
Report Abuse
SN0X is not online. SN0X
Joined: 24 Oct 2011
Total Posts: 7277
02 Jul 2012 04:00 PM
I don't know about your extremely complicated side-note but
math.floor(game.Workspace.DistributedGameTime)

is the number of players
Report Abuse
Isometricity is not online. Isometricity
Joined: 26 Oct 2011
Total Posts: 438
02 Jul 2012 04:01 PM
How is DistributedGameTime the amount of Players? I don't quite understand.
Report Abuse
TheMyrco is not online. TheMyrco
Joined: 13 Aug 2011
Total Posts: 15105
02 Jul 2012 04:04 PM
There's a proberty in the Players service called "NumPlayers" and "MaxPlayers". Their names desribe themselves.
Report Abuse
Isometricity is not online. Isometricity
Joined: 26 Oct 2011
Total Posts: 438
02 Jul 2012 04:06 PM
Thanks, Myrco.
Report Abuse
Parthax is not online. Parthax
Joined: 27 Apr 2011
Total Posts: 6941
02 Jul 2012 08:57 PM
[ Content Deleted ]
Report Abuse
NVI is not online. NVI
Joined: 11 Jan 2009
Total Posts: 4744
02 Jul 2012 09:09 PM
Or you can be a non-conformist and use #game.Players:GetChildren(). Up to you.
Report Abuse
popinman322 is not online. popinman322
Joined: 04 Mar 2009
Total Posts: 5184
02 Jul 2012 09:23 PM
@NVI

Instance.new("Part",game.Players)
Report Abuse
belial52 is not online. belial52
Joined: 10 Oct 2009
Total Posts: 8074
02 Jul 2012 09:25 PM
@Popin, Okay.

#game.Players:GetPlayers()
Report Abuse
popinman322 is not online. popinman322
Joined: 04 Mar 2009
Total Posts: 5184
02 Jul 2012 09:34 PM
@belial

game.Players.Name = "\0"
Report Abuse
Legend26 is not online. Legend26
Joined: 08 Sep 2008
Total Posts: 10586
02 Jul 2012 09:36 PM
@popin,

#game:GetService"Players":GetPlayers()
Report Abuse
popinman322 is not online. popinman322
Joined: 04 Mar 2009
Total Posts: 5184
02 Jul 2012 09:38 PM
@Legend

*opens RobloxApp.exe, replaces "Players" to "\0", saves and closes, and all Roblox clients update as expected*
Report Abuse
popinman322 is not online. popinman322
Joined: 04 Mar 2009
Total Posts: 5184
02 Jul 2012 09:39 PM
changes*
Report Abuse
Legend26 is not online. Legend26
Joined: 08 Sep 2008
Total Posts: 10586
02 Jul 2012 09:39 PM
That won't work once they release the filtering API.
Report Abuse
popinman322 is not online. popinman322
Joined: 04 Mar 2009
Total Posts: 5184
02 Jul 2012 09:40 PM
I was talking about replacing it on the production line so that all clients update without the Players service.
Report Abuse
Legend26 is not online. Legend26
Joined: 08 Sep 2008
Total Posts: 10586
02 Jul 2012 09:40 PM
I don't think you're going to be able to do that.
Report Abuse
popinman322 is not online. popinman322
Joined: 04 Mar 2009
Total Posts: 5184
02 Jul 2012 09:41 PM
But Sorcus can! :D
Report Abuse
HatHelper is not online. HatHelper
Top 25 Poster
Joined: 02 Mar 2009
Total Posts: 46305
02 Jul 2012 11:40 PM
a=game:getChildren()
for i=1, #a do
if a[i].className == "Players" then
print(a[i].NumPlayers)
break
end
end

?
Report Abuse
JulienDethurens is not online. JulienDethurens
Joined: 11 Jun 2009
Total Posts: 11046
02 Jul 2012 11:43 PM
I really think the NumPlayers property should be removed or deprecated. Does the Teams service have a NumTeams property? Does every instance have a NumChildren property? No.

We can already get that information through the GetPlayers method (#Game:GetService('Players'):GetPlayers()).
Report Abuse
Luc599345 is not online. Luc599345
Joined: 25 Jul 2008
Total Posts: 1169
02 Jul 2012 11:44 PM
^

Changing 'Players' in the assembly would successively change it's ClassName too :3
Report Abuse
kingkiller1000 is not online. kingkiller1000
Joined: 12 Dec 2008
Total Posts: 26415
02 Jul 2012 11:44 PM
@Julien

But it is much more efficient to check a property than to gather all the children into a table and check the number of them.
Report Abuse
HatHelper is not online. HatHelper
Top 25 Poster
Joined: 02 Mar 2009
Total Posts: 46305
02 Jul 2012 11:44 PM
or #game.NetworkServer:children()

can also get the sneaky people not in the players list stalking the chat.
Report Abuse
Luc599345 is not online. Luc599345
Joined: 25 Jul 2008
Total Posts: 1169
02 Jul 2012 11:45 PM
@my other post


That was meant to HatHelper... :s
Report Abuse
HatHelper is not online. HatHelper
Top 25 Poster
Joined: 02 Mar 2009
Total Posts: 46305
02 Jul 2012 11:47 PM
Luc599345, how about

local a=game:getChildren()
for i=1, #a do
local b=nil
pcall(function()
b=a[i].NumPlayers
end)
if b~=nil then
print(b)
end
end
Report Abuse
JulienDethurens is not online. JulienDethurens
Joined: 11 Jun 2009
Total Posts: 11046
02 Jul 2012 11:48 PM
@kingkiller1000

If it's more efficient, as you say, then why don't we have a NumChildren property in every instance?
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image