Hello, everyone!
I’m currently rewriting Redshift Arena’s codebase, and overall redoing the game from the ground up.
I’m at a bit of an impasse currently, involving wanting to use one input function to handle all 8 weapon hotbars.
The main thing that is halting this is the simple fact that Enum.KeyCode isn’t “One” or “Two” it’s “Enum.KeyCode.One” or “Enum.KeyCode.Two”
This is a problem since in my hotbar table, the hotbars are listed as “One, Two, Three,” and so fourth.
Here’s the code so far:
if inputObject.UserInputType == Enum.UserInputType.Keyboard then
if inputObject.KeyCode == Enum.KeyCode[WeaponStats.WeaponHotBar[inputObject.Keycode]] then
equipGun(WeaponStats.WeaponHotBar[inputObject.KeyCode])
end
end
And here is how my table is structured (within a ModuleScript.)
WeaponSettings.WeaponHotBar = {
One = {
"Pistol",
},
Two = {
"AssaultRifle",
},
Three = {
"Shotgun",
},
Four = {
"PlasmaRifle"
},
Five = {
"RocketLauncher",
},
Six = {
"SniperRifle",
},
Seven = {
"Minigun",
},
Eight = {
"PlasmaCannon",
},
}
I’d prefer to use a single input for this, rather than having to do multiple if / else statements for each gun in the hotbar.
Should also be noted that I intend on having multiple guns share the same hotbar slot. I.e. Pistol & Duel Pistol would share slot one.