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

Module Return and require help?

I want different scripts to call upon different function from my module script.

In module script

function hi()
	print("hi")
end

function bye()
	print("bye")
end

return bye , hi

In Normal script (this is where I'm confused on)

hi = require(blah.blah.ModuleScript)

hi()

1 comment

0

I want to be able to call on a diffrent function

1 answer

✓ Accepted answer

Modules

Modulescripts may only return a single function, so you might want to instead package the stuff into a table.

function hi()
    print("hi")
end

function bye()
    print("bye")
end

return {bye=bye , hi=hi}

Then in a script, you just access it like any other table.

hi = require(blah.blah.ModuleScript).hi -- Note, .hi without ()

hi()

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