Inefficient Gun System

I was working on a Gun System that uses a local script, server script, and a module script with data inside each and every weapon. Handling it like this seems very inefficient, I’m wondering if there’s a way to make it so I can handle all my guns with only a singular client-side script and a singular server-side script? Or at least a more efficient way of doing it? I will have special weapons too (like a Railgun that charges to fire or a laser weapon) so I’m not sure how to make it compatible with those.

Or maybe it’s not that inefficient to handle my system like that? Please let me know.

4 Likes

That’s not inefficient at all. Server scripts and local scripts are necessary for client-server communication and replication and module scripts let you store data about each weapon. If you take away module scripts then you’d have to store all item data inside both server and local scripts. But if you want to make it more efficient I’d recommend learning OOP. All about Object Oriented Programming

2 Likes

Instead of having it so there is a local script and server script in each weapon, you could have a listener event which listens for when a tool is added to the players character.

Personally, I have a Weapon Framework which I call .new on whenever I want to initialize a weapon.

You could have a module script inside the weapon framework module which has all the information about every weapon in a dictionary format. This is how I keep things somewhat efficient and easy to add new weapons etc.

1 Like

I meant using a client and server script inside every single weapon

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.