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: Roblox got rid of NumPlayers in the Players Property...why?

Previous Thread :: Next Thread 
DesignerDavid is online. DesignerDavid
Joined: 18 Feb 2014
Total Posts: 8422
03 Dec 2017 08:03 PM
what purpose did that serve? how inconsiderate of them smh.

if you don't know what I'm talking about: http://wiki.roblox.com/index.php?title=API:Class/Players/NumPlayers&redirect=no
Report Abuse
Negativize is online. Negativize
Joined: 02 May 2011
Total Posts: 25068
03 Dec 2017 08:05 PM
can't you just do numPlayers = #game.Players:GetPlayers()
Report Abuse
Vulkarin is online. Vulkarin
Joined: 17 Mar 2013
Total Posts: 282
03 Dec 2017 08:05 PM
because you can print it in one line who cares..


Report Abuse
128Gigabytes is not online. 128Gigabytes
Joined: 17 Apr 2014
Total Posts: 3616
03 Dec 2017 08:08 PM
Its not gotten rid of its deprecated.

Not the same thing.
They shouldn't have in my opinion, it is more efficient to have it than it is to create a table with :GetPlayers() and then get the length of it.

But whatever its not a huge difference.
Report Abuse
Vulkarin is online. Vulkarin
Joined: 17 Mar 2013
Total Posts: 282
03 Dec 2017 08:15 PM
^ You can test it in-game and it's slower


Report Abuse
128Gigabytes is not online. 128Gigabytes
Joined: 17 Apr 2014
Total Posts: 3616
03 Dec 2017 08:18 PM
There is no way I can imagine that being true, I'll test it in a minute.
Report Abuse
128Gigabytes is not online. 128Gigabytes
Joined: 17 Apr 2014
Total Posts: 3616
03 Dec 2017 08:20 PM
#game.Players:GetPlayers() 1 million times takes 0.80861711502075 seconds

game.Players.NumPlayers 1 million times takes 0.49134302139282 seconds
Report Abuse
Negativize is online. Negativize
Joined: 02 May 2011
Total Posts: 25068
03 Dec 2017 08:21 PM
'Its not gotten rid of its deprecated.'

doesn't show up in player properties, u sure
Report Abuse
Vulkarin is online. Vulkarin
Joined: 17 Mar 2013
Total Posts: 282
03 Dec 2017 08:21 PM
You have them in reverse...


Report Abuse
128Gigabytes is not online. 128Gigabytes
Joined: 17 Apr 2014
Total Posts: 3616
03 Dec 2017 08:22 PM
I just did a test with it so yes I'm sure.
Its a hidden property now.
Report Abuse
JarodOfOrbiter is not online. JarodOfOrbiter
Joined: 17 Feb 2011
Total Posts: 20029
03 Dec 2017 08:22 PM
Why would something deprecated show up in the properties? Do you even know how many properties there are hidden from the properties window anyways?
No, they deprecate things otherwise it would break every game in existence.


Report Abuse
128Gigabytes is not online. 128Gigabytes
Joined: 17 Apr 2014
Total Posts: 3616
03 Dec 2017 08:23 PM
No, I don't have them reversed.
Report Abuse
TheeDeathCaster is online. TheeDeathCaster
Joined: 19 Jun 2011
Total Posts: 1191
03 Dec 2017 08:24 PM
It might be because there's other ways of checking how many players are in a server. GetPlayers (could be) one of them. (One of the reasons I mean.)

function NumPlayersInServer()
return #Game:GetService('Players'):GetPlayers()
end

print(NumPlayersInServer()) -- How many players are in the server.

To ROBLOX, `NumPlayers` may at this point be seen as redundant, and not a lot of use for it anymore. But that's just my guess as to why it was deemed deprecated.
Report Abuse
JarodOfOrbiter is not online. JarodOfOrbiter
Joined: 17 Feb 2011
Total Posts: 20029
03 Dec 2017 08:24 PM
"You have them in reverse..."
No, 128 is good at benchmarking.
Besides, you're performing so many more operations with your version than by indexing a property.


Report Abuse
Vulkarin is online. Vulkarin
Joined: 17 Mar 2013
Total Posts: 282
03 Dec 2017 08:25 PM
Oof I am only saying that because it was the opposite when I ran it but..........


Report Abuse
JarodOfOrbiter is not online. JarodOfOrbiter
Joined: 17 Feb 2011
Total Posts: 20029
03 Dec 2017 08:27 PM
Oh sorry, that's on me I guess.


Report Abuse
128Gigabytes is not online. 128Gigabytes
Joined: 17 Apr 2014
Total Posts: 3616
03 Dec 2017 08:28 PM
local tick = tick

do
local start = tick()
for x = 1, 1000000, 1 do
local _ = #game.Players:GetPlayers()
end
print(tick() - start)
end

do
local start = tick()
for x = 1, 1000000, 1 do
local _ = game.Players.NumPlayers
end
print(tick() - start)
end
Report Abuse
Vulkarin is online. Vulkarin
Joined: 17 Mar 2013
Total Posts: 282
03 Dec 2017 08:32 PM
Oh I only did it one time...is that how you are supposed to do it?


Report Abuse
JarodOfOrbiter is not online. JarodOfOrbiter
Joined: 17 Feb 2011
Total Posts: 20029
03 Dec 2017 08:35 PM
Nah, that's like trying to measure a sheet of paper. You can do it, but more likely the inaccuracies of your caliper are going to be the only thing you measure. Measure a whole ream and you can do it accurately with a tape measure.

Do it millions of times to test, that way any minor random fluctuations in speed are negligible.


Report Abuse
128Gigabytes is not online. 128Gigabytes
Joined: 17 Apr 2014
Total Posts: 3616
03 Dec 2017 08:38 PM
One call isn't going to give you much information to go on because the speed difference will be small and also since the speed can vary you get a more accurate test the more calls you do

Also even with a single call directly referencing it should still be faster because its doing so much less, so even if you got reversed results I'm betting you probably actually got the scientific notation or whatever its called since the results would have been so small, and read it wrong.

Here are the results of calling it once
1.1920928955078e-05
8.5830688476563e-06

Second one looks like a larger number but it actually is representative of a smaller number than the first represents
Report Abuse
Exzeption is not online. Exzeption
Joined: 01 Nov 2011
Total Posts: 1312
03 Dec 2017 08:46 PM
So does anyone know why they deprecated it?
Report Abuse
JarodOfOrbiter is not online. JarodOfOrbiter
Joined: 17 Feb 2011
Total Posts: 20029
03 Dec 2017 08:46 PM
Again though, it takes fewer operations anyways. Here's what you get if you thumb through the bytecode.

getglobal -- game
gettable -- .Players
self -- :GetPlayers
call -- ()
len -- #

getglobal -- game
gettable -- .Players
gettable -- .NumPlayers


Report Abuse
JarodOfOrbiter is not online. JarodOfOrbiter
Joined: 17 Feb 2011
Total Posts: 20029
03 Dec 2017 08:48 PM
"So does anyone know why they deprecated it?"
They're on a roll, deprecating things that don't quite match their style expectations. That's good, actually. As I've said for years, their API currently looks like it was written by fifteen interns that don't speak the same language, pushed to github at the same time and the conflicts randomly resolved until it was finished.


Report Abuse
128Gigabytes is not online. 128Gigabytes
Joined: 17 Apr 2014
Total Posts: 3616
03 Dec 2017 08:51 PM
I wish they did camelCase though
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