MaxPlayers is not set immediately

When I access game.Players.MaxPlayers right away, I expect it to return the Maximum Player Count selected within the place’s configuration page. However, the property only returns 12 no matter what is actually set. It only works if I delay for a frame or so.

This can be reproduced from Studio or a live server. The screenshot below is from a live server, which is simply running this line of code from a server-side script:

print(game.Players.MaxPlayers)

maxPlayers

However, my Max Player Count is set to 6 within the place’s configuration:

maxPlayerCount


If I stick a wait() before printing out MaxPlayers, it properly prints out 6. This is arbitrary and I don’t understand why. Is it doing a network call? Is wait() always going to be enough? How can I guarantee that the value has been set? I can’t just wait for the value to change, because what if the actual max amount is 12?

This is undocumented and unexpected behavior, and thus I am reporting this as a bug.

29 Likes

Hi,

I just checked this out and can absolutely confirm the behavior–In my case, it’s 30, not 12,
and while in Studio, the 30 is fixed and never changes.
My game configuration is set for 10.
(Assuming the 30 came from a prior manual Studio config when you could change it there.)
In a live game, adding the wait() works; reports 10.
Without the wait() broken; reports 30.
(This is a server Script BTW)
This is also the case for game.Players.PreferredPlayers.

Blah

1 Like

Certainly is a bug! We will see what we can do and why this is is the way it is.

6 Likes