Am I Using Modulescripts Wrong Scripting Support Developer Forum

Am I Using Modulescripts Wrong Scripting Support Developer Forum I know a lot of people say to mostly only use modulescripts if you repeat yourself but i started using modulescripts so much that i can’t help but not to put all my main code inside of them. Hello, i’m not sure if this is the right category to put this question in, but i have been analyzing a few scripts i’ve seen developers using, and i keep seeing a pattern where people create modulescripts which are only used by one script.
1 4 What Went Wrong Troubleshooting Javascript Learn Web Modulescripts let you write code once and re use it many times. this is why it's important to keep your main code in modulescripts, and only require them in scripts and localscripts. if you are using modulescripts correctly, your game should run fine. I typically make a module scripts specifically for class objects or libraries i want to create. you want to make a script specifically with fancy ui functionality?. Intro to module scripts as projects become complex, it becomes important to think how scripts are organized. good organization practices can ensure code isn't duplicated between scripts, or becomes hard to manage. You are using modulescripts kind of the right way. separating functions into individual modulescripts is best for adhering to the dry (don’t repeat yourself) rule, yes, but having a single localscript handling all of your modulescripts can get pretty messy.

What Am I Doing Wrong Local Script Doesn T Properly Work With Intro to module scripts as projects become complex, it becomes important to think how scripts are organized. good organization practices can ensure code isn't duplicated between scripts, or becomes hard to manage. You are using modulescripts kind of the right way. separating functions into individual modulescripts is best for adhering to the dry (don’t repeat yourself) rule, yes, but having a single localscript handling all of your modulescripts can get pretty messy. How is module scripts harder to debug? it's giving you a whole callstack upon error lol, not including you being able to give it custom errors with "error", "warn" and "assert". Referencing localplayer in modulescripts is safe only as long as they run in a local context otherwise it will produce an error. If this doesn't work, try looking through the script again to make sure it's properly written. you can also try checking if any other scripts in the game are conflicting with it, or if the script is running on the right object. Try passing "window" as a parameter to the function call in the module that might work, as you're going to get the error because "window" isn't in the scope of the module, anyplace, and will be a nil value (and nil doesn't have a visible property). you have to pass in the object to have the visible property toggled.

How To Troubleshoot Common Scripting Problems Leadshook Knowledge Base How is module scripts harder to debug? it's giving you a whole callstack upon error lol, not including you being able to give it custom errors with "error", "warn" and "assert". Referencing localplayer in modulescripts is safe only as long as they run in a local context otherwise it will produce an error. If this doesn't work, try looking through the script again to make sure it's properly written. you can also try checking if any other scripts in the game are conflicting with it, or if the script is running on the right object. Try passing "window" as a parameter to the function call in the module that might work, as you're going to get the error because "window" isn't in the scope of the module, anyplace, and will be a nil value (and nil doesn't have a visible property). you have to pass in the object to have the visible property toggled.
Comments are closed.