It is not a tradition, it is a good practice. Doing game.ServiceName is indexing a property of a datamodel, this is bad because of multitude of reasons. Just think of doing game:GetService has no consequences, while game.Service does.
Then why do the same people do game.ShownServiceName?
Probably because they donât know as much as experienced programmersâŚ
This is almost 100% tradition, while also being a good practice, I never learned that I should use one over the other and so I just use game.Workspace or game:GetService(âHttpServiceâ)
workspace
is a global, which you shouldnât be using either lol.
In addition, itâs not really taxing and doesnât change much.
For most developers, itâs just a (bad) habit. The recommended way to access services is via game:GetService
; with the exception of Workspace, which has its own global variable (workspace
).
You can make hidden services visible in the Explorer under Studio Settings.
I just use workspace because it has syntax highlighting and it is shorter.
Maybe you should start doing whatâs good practice⌠If you didnât know game.Workspace is a property of game. What does this mean? An exploiter could for example reassign Workspaceâs name locally and make some scripts error. game:GetService(âWorkspaceâ) will always return correctly.
I donât see how this is that big of a deal, an exploiter can literally change anything locally if it can be changed locally.
An exploiter cannot do changes to the server? Filtering Enabled stops that. An exploit is a local script. Edit: I re read what you said and it still does not make sense. It wonât replicate therefore it wonât do any damage. Edit2: Also I am only talking about hidden services, people do game:GetService(âHiddenServiceâ) but not game.HiddenService (I do mostly use game:GetService(âPlayersâ) besides workspace)
The key word here is locally. This means it only happens on the client. This can still cause damage to some local scripts.
Iâm not saying that you shouldnât use GetService. It just isnât really that big of a deal and itâs fine to use either.
Try reading my second edit, I do use GetService on everything besides workspace, I just want to know why people always use GetService on hidden services than shown services.
Your scripts shouldnât just break when a service is renamedâŚitâs literally bad practice to use .
indexing to get children anyway. Your code is assuming Roblox wonât add a class member with that name. Remember that members have precedence over children, so when you do workspace.Terrain
you are actually accessing the Terrain
property of Workspace, not the child. Now imagine if for some odd reason Roblox adds a property called HttpService
to the DataModel, your scripts are broken. Why do people directly index for HttpService? I donât know. There are a million reasons as to why. It could be because they stubbed their toe. Or because their hair is brown. But the most probable is seeing other people do it.
Try reading my post above yours came out at a pretty bad timing lol
i think getservice for workspace is a good thing for a anti cheat in client while u change the workspace name or every service making it error and detect it by the ScriptContext for some executorâs you can grab the workspace by getservice correct me if i am wrong
Youâre not understanding, your local scripts would break. They shouldnât just break. And I was already writing mine
Actually, it does not matter if you change the name, you can still use game.Workspace
for some reason (not on other services)
I said that I use getservice in my post above, I donât get why people use game.ShownService but use game:GetService(âHiddenServiceâ)