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

How To Call A Module Script From Another Script?

Asked by 5 years ago

Any idea on how this is done? I've seen a lot of people do it and it seems really useful. Is there a certain function or...?

2 answers

Log in to vote
0
Answered by
TheePBHST 154
5 years ago

Well, you're not "calling" it. But you're just getting in it.

Something fancy called "require()" is used. So it would be like require(workspace.ModuleScript). Then the script should be like..

local MS = require(workspace.ModuleScript) -- MS means ModuleScript

MS.TableName -- In the ModuleScript is like a table or something.

So I hope you get the point. My first time with ModuleScripts was confusing, but yeah. If you're still confused and don't know how to get the Mod. Script then please LMK.

0
My bad, didn't see the comments. TheePBHST 154 — 5y
Ad
Log in to vote
0
Answered by
Nixvoid 12
5 years ago

First off, define the modulescript in the script that you want to use to call the modulescript like you do with everything else. Then, you can type: require(modulescript).

E.g.

modulescript = game.replicatedstorage.modulescript

wait() require(modulescript)

You can have a print function inside the modulescript and once the script requires the modulescript, whatever the string is, it'll print in the output.

Also, technically you don't have to define the modulescript before hand. You could just type: require(game.replicatedstorage.modulescript). It really doesn't matter.

0
this script makes me puke DeceptiveCaster 3761 — 5y
0
How else would you call a modulescript? Nixvoid 12 — 5y

Answer this question