Is there a way to duplicate the organization system used in Roblox services/objects?

I am developing a data-store modular system but I am facing some issues with organizations.

The issue is, that I am trying to duplicate the organization system that Roblox uses. For example, if I called the workspace the functions are organized in a way that I can’t call them using “.” rather than colons.

image

In fact, all the objects(baseparts) have this feature too. However, when using ‘.’ I get all the events/props. So hows all of that is possible? If it is.


I have tired researching on this form/hub but I didn’t see anything that solves my issue.

It displays all the members related to the specified object. Intellisense I think it is, it can actually detect fields in custom user data as well, in some cases.

e.g:

–//some module

local x = {}

function x.y()

end

return x

Pretty sure it’ll have y pop up when I index the loaded module.

This may be of some use to you.

Thanks for the source, I will read through it!

EDIT: Is there any way to implement this using Modulescripts though?

Roblox uses OOP for their API.
I won’t go in depth over OOP as there are already posts that cover that.

But this is a widely used implementation of OOP in Lua

local Person = {}
Person.__index = Person

function Person.new(name)
  local self = setmetatable({
    name = name
  }, Person)

  return self
end

function Person:sayHello()
  print(self.name .. "  says hello")
end

-- you can now construct a new instance of Person
local myPerson = Person.new('John')
myPerson:sayHello()

I am not looking for tutorial that teaches me to code OOP programming, if you read my post, I said how to implement the way of organization they use for their services. For example, If I used colon to index something in a table, it would obviously index methods only while periods index everything while in roblox objects/services the colons index functions/methods while periods only index events/props. And thats exactly my question, how they do it?

Its probably something that only works for the Roblox API.

I don’t think Luau allows you to hide methods from intellisense when using ..

However Luau will complain in strict mode if you are using . because of incorrect parameters, unless you explicitly pass the self parameter

1 Like

It seems like the only way to achieve what I want is by having 2 tables, one has the functions and the other has the properties.

While I knew I can do this, I wanted to have a more organized look that just works like Roblox objects/services. At least, by using module scripts.