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...?
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.
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.