Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

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

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?

2 comments

1

I use game.PATH normally cause I know it is already there, it was how I made scripts however I do use waitforchild().

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

2 answers

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].

2 comments

1

Oh my god, same!!

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.

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)

This discussion is preserved as it was. New answers, comments, and votes are closed.