Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Do you prefer to use game.[Path] or game:GetService(SERVICENAME).[Path]?

Asked by 4 years ago

There isn't really a difference between

game.Workspace and game:GetService('Workspace')

but when it comes to scripting, everyone has a different preference. I would like to know what you guys preferences are, and why.

Personally, I always use game:GetService() function because I can create new services, but what is the reason for you guys using it. I am honestly curious. Is it the way that you were taught? Is it easier for you?

1
I use game.PATH normally cause I know it is already there, it was how I made scripts however I do use waitforchild(). Frometa1998 35 — 4y
1
if anything can briefly tell me what it is like game:GetService() I would use it since it makes thoughts clearer instead of saying game.Workspace 123nabilben123 499 — 4y

2 answers

Log in to vote
1
Answered by 4 years ago

Personally I use game:GetService(SERVICENAME).[Path] for most things, but for several cases I prefer the game.[Path] because it's more readable like in the case of game.Workspace but I mainly use game:GetService(SERVICENAME).[Path].

1
Oh my god, same!! JayShepherdMD 147 — 4y
1
Very similar answer to Ceramic. It really just comes down to specifically what I'm doing but a majority of the time I prefer GetService since it tends to stand out a bit more in scripts so I can find it later if need be. XxTrueDemonxX 362 — 4y
Ad
Log in to vote
1
Answered by 4 years ago

There is a difference between the two, one references the service Workspace and another references the object Workspace. It is really not a server-side problem anymore, but malicious scripts could rename the services and break your scripts. Also since some services are hidden its a lot more uniform to just use GetService for every service then use GetService for some and the naming method for others. (Was taught without GetService because OG scripting was just about making it work)

Answer this question