Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Help With Modules?

Hello there, I don't seem to understand the concept of Modules, so I was wondering if anyone could help me or send me a link to a place that can help me, I couldn't understand it in the Roblox website sadly.

2 answers

✓ Accepted answer

They return stuff.

--I'm horrid at explaining stuff
--in a moduleScript--
function thing(otherThing)
	--put stuff here
end
return thing
--in a script--
thing = require(theModuleScriptObject) --will return the function thing
thing(10)
--this also helps with sending over many functons
local tab = {}

function tab.f1()
	--stuff
end

function tab.f2()
	--stuff
end

function tab.f3()
	--stuff
end
return tab
--in a script--
module = require(theModuleScriptObject)
f1 = module.f1
f2 = module.f2
f3 = module.f3

That's pretty much it. Leave a comment if this didn't answer your question.

1 comment

0

Wow, thanks alot!

This discussion is preserved as it was. New answers, comments, and votes are closed.