Shared table problem

  1. What do you want to achieve? Keep it simple and clear! Im trying to add autocomplete to the shared table so its easier to script for me and is more cleaner

  2. What is the issue? Is it possible to add AutoComplete to “shared” at all? The photo below is photoshopped

  3. What solutions have you tried so far? Asking chat gpt, but it only works in testing

Assuming shared is a module script, if it has methods and you require it directly from its container Roblox should pick up on its methods in the script editor.

E.g

-- Module Script
local shared = {}

function shared.SomeMethod() 

end
-- Any other script
local shared = require(game.ReplicatedStorage.shared)

shared.--autofills

that really works. Didn’t even think about it haha!.. thanks though!

1 Like

I know this has been solved; I just want to explain why you can’t get autocomplete on shared!

When using the shared global, you can’t get autocomplete. Autocomplete generally comes from type annotation/type inferring, so like this:

local tbl = {
    ["key"] = 1
}

--you would get table autocomplete for tbl's 'key' the same way it's inferred:
local tbl: {["key"]: number} = {
    ["key"] = 1
}

Luau is a dynamically typed language; types are inferred automatically.

Since Luau doesn’t know what shared will contain during development, i.e. what’s added by other scripts, it doesn’t add this to the basic type annotation. When you use a module, Luau knows what it contains and can give you autocomplete based on what the contents of the module is.

alright, will know that. Thanks !

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