What does 'require' do in Roblox scripting?
+
In Roblox scripting, 'require' is used to load and run a ModuleScript, allowing you to reuse code across different scripts by accessing the module's returned table or function.
How do I use 'require' to access a ModuleScript in Roblox?
+
To use 'require', you first get a reference to the ModuleScript instance, for example: local module = require(game.ServerScriptService.MyModule). This runs the module and returns whatever the ModuleScript returns, such as a table of functions.
Can I require scripts from different places in Roblox?
+
Yes, you can require ModuleScripts located in various services like ServerScriptService, ReplicatedStorage, or StarterPlayerScripts as long as the script has permission to access that location.
What type of scripts can be used with 'require' in Roblox?
+
Only ModuleScripts can be used with 'require'. Regular Script or LocalScript cannot be required because they do not return values and are meant to run independently.
How does 'require' handle repeated calls to the same ModuleScript?
+
When you require the same ModuleScript multiple times, Roblox caches the result and returns the same module instance each time, ensuring that the module's code runs only once.
What are common errors when using 'require' in Roblox?
+
Common errors include requiring a non-ModuleScript, trying to require a ModuleScript that does not exist or is not accessible, or syntax errors inside the ModuleScript itself.
Is it possible to pass parameters to a ModuleScript via 'require' in Roblox?
+
No, 'require' does not support passing parameters directly. Instead, you return functions or tables from the ModuleScript and call those functions with parameters after requiring the module.