Help with Module Scripts

So I have been making some modules which I publish here and there, basic ones but still.
And I wanted some tips, things that most people don’t go over on modules.

For example, what is “self”?

I wanted some tips for things like that so that I can make my modules better.

1 Like

So when you require a module. and then activate a function within a module,

When you hit module:HelloWorld(functionparam1)

What it will do is have a special hidden variable named self, self is the actual module in the first place.

Meaning you can do something like this:

-- Module
local module = {}

function module:Helloworld()
	self.WHAT()
end

function module.WHAT()
	print("Printed")
end

return module


--script

local Yes = require(script.ModuleScript)

Yes:Helloworld()

--result

> Printed

Edit:

If you feel this solved your problem be sure to mark it as such, helps me out :slight_smile:

3 Likes

It isn’t a solution per-say, as I’m finding tecnics, and trying to learn so.

1 Like