How do you properly referance Players

So there are two methods to calling Players either:

game:GetService("Players")

or

game.Players

On all of the API referance they use the first option, but I have been scripting for a while now and game.Players works perfectly fine. Is either the “correct” way? is either way faster?

Using :GetService is recommended for every service, not just Players, but I use game.Players when accessing LocalPlayer in LocalScripts.

It’s also possible to use game:FindFirstChild("Players") or WaitForChild(), but seeing as you have a fully functional built in call for getting services, I wouldn’t see why.

Do the using GetService provide any kind of performance boost or something like that?

Not that I’m aware but it is far more reliable than using anything else.

Probably not, for things such as Players or Workspace you’ll almost always have access to them (they are responsible for gameplay after all).
However something such as DataStoreService requires GetService() as it isn’t enabled by default.

1 Like

Before making a forum post, please try to search before you create to avoid spam.
But I hope this helps, refer to this post.

TL;DR Some services aren’t loaded by default, which is the primary reason to use GetService much more. Although you should use it for all services, not for that specific reason but because it is the canonical way to fetch services. Read the post to find out more.

1 Like