Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Module Return and require help?

Asked by 8 years ago

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()
0
I want to be able to call on a diffrent function gaberdell 71 — 8y

1 answer

Log in to vote
0
Answered by 8 years ago

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()
Ad

Answer this question