I want to make equipping guns easier and more optimized, but I don’t know where to start.
My current code works, its just not the best way of doing it. I want to add up to 5 slots of weapons you can equip.
local Loadout = {
--This is the loadout of which weapons the player can equip.
"KaBar", --1
"Nothing", --2
}
I have tried to see if anyone else asked this but it doesn’t seem to fit what im trying to do.
**Below is how I handle equipping weapons. But I feel as if it is tedious to do ‘CanEquipPrimary’ and ‘CanEquipSecondary’. Is there any easier way of handling this? Instead of making 5 variables, is there a way to do it?
if k.KeyCode == Enum.KeyCode.One and CanEquipPrimary and Loadout[1] ~= "Nothing" then
CanEquipPrimary = false
CanEquipSecondary = true
CanEquipThirdary = true
primaryEquipped = true
equip(Loadout[1])
UiEffectsModule:primaryOrSecondary("p")
elseif k.KeyCode == Enum.KeyCode.Two and CanEquipSecondary and Loadout[2] ~= "Nothing" then
CanEquipSecondary = false
CanEquipPrimary = true
primaryEquipped = false
CanEquipThirdary = true
secondaryEquipped = true
equip(Loadout[2])