Typically people opt to use game:GetService("Players") as to ensure you get the Service whereas game.Players just gets the first thing it finds called Players, which could break in the event it is not what you expect.
There’s no other difference besides that I believe, it is more recommended to use game:GetService() for obtaining services to ensure you get the service that you want
These are practically the same. In my opinion you should always use the second one, it’s shorter and neater. The only difference is the first one is safer, this is because :GetService() does a ClassName lookup, and doesn’t give back a result depending on the Name. What this means is if someone (you or a malicious client) changed the name of a service on his end, the game.Service way will error (this is since services are actually a child of game, with Workspace being an exception being a property).
For things only visible to the server, this is not a problem since the only person that could change the name is you, on the client, who cares! If an exploiter changes the name they will get errors, no one’s affected.
You should absolutely not use the second one, since you need GetService in some places and it’s just consistency. Lots of services are not named the same their class name; try printing game.Instance.ClassName or looping through the DataModel’s children. On top of that, if you’re writing open source code, people are fully able to rename services in their game to whatever they want. game.Players might work in your places, but others might have it named players, p, or something else. GetService creates services that don’t exist yet, too: see Teams. (Exploiters can also locally rename services and break your game if you use the second method, but them breaking their own client is less of a concern than the other reasons for using it. I’m sure they have easier ways to stop LocalScript execution.)
In the second case you are calling the DataModel child Instance. In the other way you are calling directly the service which means : if you change the Players’ name instance you will access into that service by using game.newServiceName ( in that case the new name of the Instance) but always game:GetService("Players") . If you want to secure (very few) your game changing some services’ names ,using game:GetService() you won’t have the problem of changing the name of the service call.
game.Players.Name = "banana"
-- now to call Players service you need to use the Name of the Instance
game.banana --now is players
-- with GetService() function you don'y have to worry about instance name so you can always call it with :
Pollo, exploiters can access basically anything you can with a local script with some additions and deductions. This is not for the sake of security whatsoever.
The only difference is the way it finds the ‘players’.
Players = game.Players - Directly try’s to access the child ‘Players’ (Basically a folder)
Players = game:GetService(“Players”) - Gets the Player folder through the service rather than trying direct access. Will find even in the case of changes to game.Players e.g changing parent or name.
The only relevance exploitation has to this is if you are getting it locally and an exploiter has changed the location or name of players. This is basically never done by exploiters as it will make the game unplayable for them which will remove the point of them exploiting in the first place. This means the only people this would effect are those exploiting, so I will repeat what everyone else has been saying. It simply doesn’t matter, only game:GetService(“Players”) accounts for changes to game.Players.
Well, if you look over the source code of some popular games that have open sourced like Prison Life (with good scripting and UI design), they always use GetService() and WaitForChild(). game.Service, in my opinion, is very unneat, because anything could happen to the service, it could get renamed, it could not be loaded yet etc.