Service names being built-in to global

As a Roblox developer, it would be a nice QOL change to have all services (or the most used ones) being immediately accessible as a global built-in without constantly having to use GetService() (such as workspace) at the very top. As Roblox doesn’t autofill local ReplicatedStorage = game:G I’d have to manually type it out every time.

it would improve my development experience a little when creating a new script. Eliminating this small hurdle whenever I create a new modulescript.

Aside: Don’t hesitate to send feature requests

This change is a nice demonstration of the power of feature requests.

In total this change only took about a day of work to implement, test, and release. However it will likely save the community countless hours
Shorthand Properties Panel Input

9 Likes

Some services are not immediately available, and I believe calling GetService when it doesn’t exist will yield, or at least do some work before returning. Having it immediately as a variable may potentially be nil.

3 Likes

It would be up to the engineer to make it work similar to GetService() for those specific cases. Otherwise most of the other commonly used services are readily available.

1 Like

An engineer actually responded to this.
Basically, not all of the services are available/exist at all times, calling :GetService() creates the service if it hasn’t been initialized yet.
And this is actually the case for a lot of services.

2 Likes

Various issues with doing this, here’s a couple:

  • As mentioned, not all services exist by default. This could be worked around by adding additional machinery to the environment but that would come with additional performance costs to accessing game / workspace / etc.

  • Namespace pollution. Do you want every service in your code completion popup? What if I told you there’s about 50 services with publicly accessible methods on them, do you still want all of them in the code completion popup?

Worth noting that auto-editing scripts to include the used services could be implemented as a Studio plugin using the LSP API.

9 Likes

This person actually created a very neat studio plugin that autocompletes service names, have been using it for a long time, and literally forgot about writing down service variables.

2 Likes

Wow, this is great! Features like these makes using the Script Editor so much more better. I wish to see this natively implemented but for now I’ll consider this the solution : D

1 Like

Can there be better documentation on this? I’ve wanted to use it for a long time now but at it’s current state I think it’s hard to understand.

1 Like

I wouldn’t say that the documentation on the LSP API is bad. Consider for example the documentation on RegisterAutocompletionCallback, granted the LSP API surface is more complex than most Roblox APIs.

Were you looking for something more in the vein of an example plugin using the API?

1 Like

Yeah mainly just an example, I understand what it does as I have tried it, but an example would help with it a lot.

I feel like the given code sample is really basic and doesn’t seem like it could be an actual practical usecase.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.