Why can't we direct reference some services?

Why do i have to use getservice on replicated storage to put something in there for example, and why can I just direct reference ServerStorage if I want to put something in there. (I don’t know if you can direct reference replicated storage to do things with it, because every code i see uses getservice and I also have been doing that forever.
So yeah, what’s up with this getservice thing?

1 Like

Well doing GetService makes your game less exploitable.

And why would that be the case?

I suggest watching some videos like this one: - YouTube
They’re really helpful.

4 Likes

Oh, didn’t know these actually existed, thanks for the tip!

I’m pretty sure you can use a direct reference to ReplicatedStorage (game.ReplicatedStorage is valid), GetService is considered good practice because if you renamed that service to something else or if it’s not yet loaded, GetService will still work but direct reference won’t. Tho it won’t make your game less exploitable.

2 Likes

Curious–Has anyone ever run into a game.<Service> “not yet loaded” issue?

1 Like

Yes have happened once for me with HttpService, after that I referenced it with GetService.

1 Like

Yeah, I thought the ‘less exploitable’ part was a bit off either lol.

As you can see in the screenshot below, this is because not all services directly use that name. If you turn on seeing all services not just primary ones, you can find this group of services that don’t have a name and are just called “Instance”.


Name: Instance
ClassName: UserInputService

Good point, however I don’t think that’s what the OP was driving at. But it does make one wonder then
why doesn’t Roblox have all Services that could have “not yet loaded” issues, such as HttpService
as @TheMirrorGameCreator mentioned, be named “Instance” just like UserInputService.

1 Like