So I see that many people use ModuleScript all the time in their games. I know that is some kind of script that you can use to make built-in functions and stuff. But what is the reason devs choose them over regular scripts more often?
2 Likes
Because any script can access them, they can store tables, functions. Main reason is because its like a service that can be accessed anywhere, instead of repeating the same code in different scripts, you can require a module and use it.
2 Likes
In what cases can I use it in my game?
1 Like
A custom HTTP or DataStore wrapper module being used in multiple server scripts.
1 Like
A table for storing data:
GameData = [
ServerUpTime = 0000,
PlayersInServer = 40,
]
Functions for global access:
function Module.PrintMessage(message)
print(message)
end)
1 Like
Let’s take that you want something to happen when a an event fires in game right.Now instead of writing code everytime it happens,module allow you to require the code from it and use it.
1 Like