Provide Typed References to All Services So that Intellisense Can Work

I have a lot of code that looks like this:

local UIS = game:GetService("UserInputService")
local CAS = game:GetService("ContextActionService")
local GUI = game:GetService("GuiService")
local MKT = game:GetService("MarketplaceService")

Some of which I straight up copied from the ROBLOX wiki.

The problem with this code is that if I type “CAS:” or “CAS.” I get no intellisense or autocomplete options because the parser has no idea what the type of the token “CAS” is.

The reason, historically, that we have these “GetService” calls is because not all services were created at run time automatically, so sometimes (for example) game.TeleportService would be nil. I propose that we create them all at run time automatically.

Then I could write

“game.MarketplaceService:” and get autocomplete suggestions.

Alternatively we could introduce calls like

“game:GetMarketplaceService()” which would suffice, but is uglier in my opinion because writing code with interstitial parens is probably harder for new developers because you really have to understand the difference between a function and an ivar.


Services obtained with GetService have autocomplete suggestions if that’s what you’re talking about.



Interesting thing I noticed.

This gives autocomplete:

But the colon after CAS does not:

1 Like

I swear I’ve seen autocomplete working on locals in the Lua editor before.

Was this never the case?

It looks like it doesn’t.

I know it can’t be done perfectly due to Lua’s type system, but it would be really helpful for objects people deal with once every 6 months. What if I promise not to do anything funky with changing the types of my variables and we build a giant hashtable of all the tokens in the code indented by scope and do a best-shot autocomplete?

Who has to look up what fields exist on this object every time they use it? Probably everyone.



It may be a little hard, but ‘constant’ syntax would be a pretty cool thing to have. Something like const MKT = game:GetService("MarketplaceService") - it would work just like a local, but cannot be re-assigned after it has initially been set. That way, autocomplete can be done relatively simply on services.

Best and easiest would be using comments, something like:

-- Instance/MarketplaceService
local MS = game:GetService("MarketplaceService")

local PLRS = game:GetService("Players") -- Instance/Players

Later on, maybe we could allow plugins to do stuff like:

local Intellisense = Plugin.Intellisense -- or intellisense() like settings()
intellisense:AddType("Instance",function(str) -- rest of comment
	local data = getApiDumpThing(str:sub(2)) -- after the slash
	return {
		WaitForChild = {"WaitForChild(string name)","Blablbla"},
		Another = {"title","description"},
		-- etc

-- @char Instance/Model
-- @plr Instance/Player
-- @item customType/Item
local function f(char,plr,item,amount)
	-- blablabla

This miiiight be something that won’t be added (soon), but it would be very handy/
(since lots of people start to use OOP (classes etc) plugins can add support for them)

1 Like

This is because CAS is a user-defined local variable. Currently, Intellisense does not check the type of a user variable. In the first example, Intellisense is working off of GetService, not CAS.

It is still doing some magic to match GetService(“MarketplaceService”) to the type MarketplaceService. Whatever intellisense library we got can’t do this out of the box because it doesn’t know enough about our system, someone had to go in and make this magic work.

What if there was a little more magic?

1 Like

1 Like