So the module below contains a dictionary of weapon names and the function within the module checks the parameter “item” name and if it matches with the ones in the table it will take the clone of the weapon and put it into the player’s backpack.
Only thing I’m not satisfied with is how inefficient this feels, every time I make a new weapon I have to go back into the module and create a new if statement for the new weapon.
I’d like to know a more efficient way of doing this, code below.
You could have each loadout be a table of instances that need to be cloned into the player’s backpack. That way you do not have to have a different check for every new weapon, anything in the table is part of the loadout. Using a table also has the advantage that you can convert it to/from a string (using HttpServcice JSONEncode) which you can then save/load to a datastore.