@johnnya
Roblox Oct 26, 2026

what does require() actually do in roblox studio

Every tutorial uses require with a modulescript and I just copy it without understanding. What does it return, and when should I use a modulescript instead of putting everything in one script?
1

Leave A Reply

Log in to post an answer.

1 Answer

sara_65 Oct 29, 2026
johnnya
it runs a ModuleScript and hands you back whatever that module returns, usually a table of functions. the part that matters: the module only runs once per side. the first require on the server runs it and caches the result, and every require after that gets the exact same table back. so if you keep state in a module, every script requiring it sees the same state. client and server each get their own copy though, they don't share.