How should I setup/structure my placement system? (Server vs. client)

Hey!!

Thanks for looking into this with me…

I need help :slight_smile:

I have a placement system that I am working on, but I am not sure were to put things/how to structure things.

I know that active-placement objects should be moved locally (on the client) and post-placement objects should then be placed on the server.

The part I don’t understand is the best way to set it up.

Should I have my local placement module in ReplicatedStorage? Should it be in StarterGui with my GUI elements?

Also, for practicality, should I have an entire single module dedicated to the system, or several modules linked together, each performing a different task?

For more knowledge on the system itself, it has 7 main parts for active-placement. An object placement system, wall placement system, floor placement system, roof placement system, window/door placement system, lighting/ceiling object placement system, and several other editing features for post-placement.

With this in mind, what do you think is the best route to go when setting this up?

1 Like

I forgot to mention that the system also has basement placement and pool placement systems in place.

NOTE: None of the features have been made yet. They are all theoretical.

Client modules should go in StarterPlayerScripts, while shared modules are in ReplicatedStorage. This helps other programmers know which environment a module is used from.

Use as many modules as you need to; they exist so you can break your code up into smaller pieces that are easier to work with. Each module should be dedicated to doing one thing, this is called separation of concerns.

2 Likes

Got it! This is very helpful and makes sense.

I do have one question: How does this work with constructor functions? (function.new()) Because the client placement is dealt with per the player, and is not shared, then does this mean I wouldn’t need to use them?

If you don’t need multiple separate versions of an object, then you don’t need a constructor, or to follow the Lua oop __index metatable pattern. When only 1 copy of a class can exist it’s called a singleton, otherwise they’re referred to as instances of a class. (Construction is often referred to as instantiation)

1 Like