local UIS = game:GetService("UserInputService") local WeaponEquipped = false UIS.InputBegan:Connect(function(input) if input.KeyCode == Enum.KeyCode.Q and script.Parent.Text ~= "Weapon slot empty." and WeaponEquipped == false then WeaponEquipped = true game.ReplicatedStorage[game.ReplicatedStorage.Slot.Value].Parent = game.Players.LocalPlayer.Character script.Parent.Text = 'Press "Q" to unequip your '.. game.ReplicatedStorage.Slot.Value.. "." end end) UIS.InputBegan:Connect(function(input) if input.KeyCode == Enum.KeyCode.Q and script.Parent.Text ~= "Weapon slot empty." and WeaponEquipped == true then WeaponEquipped = false game.Players.LocalPlayer.Character[game.ReplicatedStorage.Slot.Value].Parent = game.ReplicatedStorage script.Parent.Text = 'Press "Q" to equip your '.. game.ReplicatedStorage.Slot.Value.. "." end end)
First of all, we could do all of this in one event connection. Just some edits and we should be good to go.
I would explain all of this, but I'm just too lazy to do that, so here's the code. Let me know if you have any questions or issues.
Also you might wanna format this, just saying.
local UIS = game:GetService("UserInputService") local WeaponEquipped = false UIS.InputBegan:Connect(function(input) if input.KeyCode == Enum.KeyCode.Q and script.Parent.Text ~= "Weapon slot empty." then if WeaponEquipped == false then WeaponEquipped = true game.ReplicatedStorage[game.ReplicatedStorage.Slot.Value].Parent = game.Players.LocalPlayer.Character script.Parent.Text = 'Press "Q" to unequip your '..game.ReplicatedStorage.Slot.Value.."." else WeaponEquipped = false game.Players.LocalPlayer.Character[game.ReplicatedStorage.Slot.Value].Parent = game.ReplicatedStorage script.Parent.Text = 'Press "Q" to equip your '..game.ReplicatedStorage.Slot.Value.."." end end end)