Abudiak duels 2 codes1/20/2023 Using require on a ModuleScript in a LocalScript will run the code on the client, even if a Script did so already on the server. It’s important to know that return values from ModuleScripts are independent with regards to LocalScripts and Scripts, and other environments like the Command Bar. So, you should define functions or groups of functions in ModuleScripts and have your Scripts and LocalScripts call require on your ModuleScripts. Having multiple copies of a function is disastrous when you need to change that behavior. When you write a function, write it only once and use it everywhere. ModuleScripts are essential objects for adhering to the don’t-repeat-yourself (DRY) principle. ModuleScripts run once and only once per Lua environment and return the exact same value for subsequent calls to require. This value is then returned by a call to require given the ModuleScript as the only argument. ![]() ![]() ![]() A ModuleScript is a type of Lua source container that runs once and must return exactly one value.
0 Comments
Leave a Reply.AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |