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 9 years ago

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

In module script

1function hi()
2    print("hi")
3end
4 
5function bye()
6    print("bye")
7end
8 
9return bye , hi

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

1hi = require(blah.blah.ModuleScript)
2 
3hi()
0
I want to be able to call on a diffrent function gaberdell 71 — 9y

1 answer

Log in to vote
0
Answered by 9 years ago

Modules

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

1function hi()
2    print("hi")
3end
4 
5function bye()
6    print("bye")
7end
8 
9return {bye=bye , hi=hi}

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

1hi = require(blah.blah.ModuleScript).hi -- Note, .hi without ()
2 
3hi()
Ad

Answer this question