Differences between Game.Players and Game:GetService ("Players")

i dont understand why it want have Game.Players and Game:GetService (“Players”)
i want someones explain about it

2 Likes

The GetService method basically checks to see if the given service is valid. If it is not valid, it will error.
If it is valid but hasn’t been created yet, then it will create it. Finally, the service will be returned.

For a more detailed description, check out the official documentation.

4 Likes

GetService is the canonical way to fetch a service. It finds a service by its ClassName in the DataModel. You should never use the first one because it’ll cause your code to look inconsistent when you are required to use GetService to access a service and services don’t have constant names (they can be changed and some aren’t even properly named in the first place).

1 Like

GetService() checks if the given service already exists. If it doesn’t exist then creates it. Either way, it will return the service.
GetService is not necessary with the services such as Workspace, Players or ServerStorage, but it’s always better to use it just in case.