Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

What lines of code should my module script contain to be beneficial to my organization?

I'm trying to become a more organized scripter, and I know that module scripts are a big help in that. My problem is that I don't understand them all that well. Do you store functions and variables in there? If somebody could explain the uses that they have that would be very helpful. Please don't comment the roblox wiki article, as I have no idea what it is trying to tell me.

2 comments

0

To answer your question about variables and functions - yes, you can. Make sure the script is very coupled (meaning that everything is related to each other). Think of it like OOP: for example, a new 'object' can be created with made up 'new' function inside the module - all 'objects' are tables/metatables. Think of any Roblox function, like Vector3 for example.

0

You don't use Modules to actually run your code with logic of course. Hope that answers some of your questions, that's how I use modules, but you can do whatever you want with them tbh.

1 answer

I like to think of module scripts as a script to store things without making your other scripts look messy. But I also like to think of them as a way of making like settings for scripts. And there’s also the other and probably the most effective use of module scripts known as OOP(Object Oriented Programming) and this is what I use it for the most. For example, you want to create a car. But even if you were to create a car with a simple function, you should be able to spawn as many as you want without typing the same things. This is called a constructor. For example car.new(arguments). You could use a module script and combine them with meta tables to create your own objects with classes. I also learned from someone that OOP is only used in things that you want to start and end. I’m not a great teacher but there are lots of resources out there on OOP. Thanks

This discussion is preserved as it was. New answers, comments, and votes are closed.