Help Melee Foundation

I’m adding a combat system to my game where the player can unlock and buy weapons that they can add to their hotbar to use around the game.

The issue is that I’m not too sure how I want to set this up. My idea right now is that I have a folder of all the weapons in game inside of ServerStorage, then have a ModuleScript that has a function that can find any weapon inside of the aforementioned folder, and then add it to a table that represents the player’s owned weapons. The ModuleScript might have an array that has every weapon’s stats organized so that other script can pull those stats for other mechanics.

I was also thinking of using another script to handle when the player equips a weapon to their hotbar and when they press the keybind to actually hold said weapon, then a script (the same one or a new one I’m not sure) will handle actions related to the weapon itself (attacking, blocking/parrying, special abilities, etc.).

This is my basic idea of the foundations for my weapon combat system although I would like feedback if there are better ways to set this up.

(If anyone would like more specific details just ask.)
(I’ve also already posted this before but it only got 24 views in 17 hours so I’m reposting it)

1 Like

Honestly that sounds good. In general the best advice I can give is to make sure that each system can operate as independently as it reasonably can so if one ever needs to change it doesn’t break others (a concept called decoupling). Your proposed system already sounds good for this though. A system to manage finding a weapon and query if a user owns it. A system to handle equipping the weapon. A system for handling the weapon when it does get equipped. Any one of those can be updated without breaking the others so even if you don’t get it perfect rn, it won’t break your whole game if you need to rewrite one later (though to be clear it sounds like a good direction anyways).

Thank you so much!! I wanted to hold on using my idea because although I am a decent programmer, I haven’t really done a melee system like this before and I wanted to get a second opinion on it before actually committing to the bit. Although, if all seems well then I’ll try to implement it.

1 Like