Best way to manage complex world objects

I’ve been thinking about complex world objects for games recently. In other words, they would be models that could have corresponding values and methods. This is possible with ModuleScripts, but I’m pretty sure becomes an issue when creating many of them. As far as I know, there’s no way to “clear” the existence of a required module which would cause issues down the road.

How would you go about making objects like this but without repeatedly requiring a module? Preferably you could create an object-oriented class to be able to run something like…

local worldObject = Object.new()

…and not have to worry about how other scripts would access the information inside of the created object. Without creating a new module which would have to be required, I’m not sure how you can pass in methods and values that would be related to that specific object. What would be the workaround to this?

1 Like

I still haven’t solved this issue. Does anybody have something to suggest?

If you create a model and attached a local script as a child containing the aspects of what you want the model to carry out and placed the model in ServerStorage and used a serverscript to clone that model into workspace and renamed it then would it not do what you wanted.
I am assuming that amongst other things the local script would check if it was to be awake or not by checking some where like perhaps your controller modulescript and that the controller would control the objects actions as you would like them.

Well currently I’m using a ModuleScript to store a reference to a “Build” object (created using my Build.new() method). The only issue is it’s not a great idea (as far as I know) to do this because it would just keep creating required references whenever you want to access that information. That’s the major issue with this way of going about it.

Alternatively you could just create a ModuleScript on the server which stores all of these “Build” objects in a big table so you can just do something like Builds[BuildWorldModel] and get a reference to the created object. I’m not too sure of the downsides to this system though. This is the best thing I can come up with to fixing the given issue though.

I have used a table containing the details of the models to be established as objects, their location and any special setup options for each level of my game.
I have a Game controller script that uses this table to build the world.
This gives me a faster startup and only a slight delay at level change time.
I don’t know if this help you but it has proved good for me.

This is somewhat like the system I mentioned; that might mean it’s a good idea. I’m still not sure if it would cause any issues down the road or any memory leaks, though.

All I can say to conclude this is from my testing with 10 users and 1000 objects there has been no significant indications of stress or memory leaks.
I am not able to get more testers than that so its only an indication.

1 Like