How to use this type of function with modules?

Hi guys, I was wondering how could I do this with my module scripts?
here is an example
in Topbarv3 it has this exact same function thing.

Ive looked for it online but couldnt really find anything?

local C = require(game.ReplicatedStorage.Icon)

C.set()
	:Option("1")


C.set() is a constructor that creates an object that uses self. When you run the C.set():Option("1") line you basically do the following:

local object = C.set()
object.Option(object, "1") --self means that the object itself is passed as first arg
--this is hidden through the use of the : symbol when calling the function

For organization there’s a chance that set is a submodule under the main Icon module specifically for that object.

1 Like

what your describing is known as “method chaining”, here’s a link to a very in-depth and well made article on the topic

1 Like

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