okay, so i think i made a decent equip and unequip logic system thing for the tool system, do you think this is okay or should i change anything/ redo anything ? it is in a localscript
local UserInputService = game:GetService("UserInputService")
local Keybinds = {
Main = Enum.KeyCode.E,
Seconday = Enum.KeyCode.R
}
local CurrentWeapon = "none"
local IncomingWeapon = "none"
local function Equip(weaponType_)
IncomingWeapon = weaponType_
if CurrentWeapon == IncomingWeapon then
CurrentWeapon = "none"
IncomingWeapon = "none"
else
CurrentWeapon = IncomingWeapon
IncomingWeapon = "none"
end
print(CurrentWeapon)
end
UserInputService.InputBegan:Connect(function(inputObject_, gameProcessedEvent_)
if gameProcessedEvent_ then
return
end
local KeyCode = inputObject_.KeyCode
if KeyCode == Keybinds.Main then
Equip("Main")
elseif KeyCode == Keybinds.Seconday then
Equip("Secondary")
end
end)
i modeled it after roblox’s where if you click on a new tool while having one already, it auto unequips that and equips the other one, and if you try to equip the same tool, it unequips.