local function OnInput(input, Chat)
if Chat then return end
local GetKeyCode = input.KeyCode
if GetKeyCode == Enum.KeyCode.One and HasTool ~= 1 then -- Pressed One
if AK47 == true then
game:GetService("Players").LocalPlayer.PlayerGui.Main.Main.Primary.BackgroundTransparency = 0.5
game:GetService("Players").LocalPlayer.PlayerGui.Main.Main.Secondary.BackgroundTransparency = 1
game:GetService("Players").LocalPlayer.PlayerGui.Main.Main.Primary.ImageLabel.ImageTransparency = 0
game:GetService("Players").LocalPlayer.PlayerGui.Main.Main.Secondary.ImageLabel.ImageTransparency = 0.5
HasTool = 1 --To Not Equip Tool Multiple Times
Humanoid:EquipTool(tool)
end
elseif GetKeyCode == Enum.KeyCode.Two and HasTool ~= 2 then -- Pressed two
if Glock == true then
game:GetService("Players").LocalPlayer.PlayerGui.Main.Main.Primary.BackgroundTransparency = 1
game:GetService("Players").LocalPlayer.PlayerGui.Main.Main.Secondary.BackgroundTransparency = 0.5
game:GetService("Players").LocalPlayer.PlayerGui.Main.Main.Primary.ImageLabel.ImageTransparency = 0.5
game:GetService("Players").LocalPlayer.PlayerGui.Main.Main.Secondary.ImageLabel.ImageTransparency = 0
HasTool = 2
Humanoid:EquipTool(tool2)
end
elseif GetKeyCode == Enum.KeyCode.One and HasTool ~= 3 then -- Pressed two
if crazygun == true then
game:GetService("Players").LocalPlayer.PlayerGui.Main.Main.Primary.BackgroundTransparency = 1
game:GetService("Players").LocalPlayer.PlayerGui.Main.Main.Secondary.BackgroundTransparency = 0.5
game:GetService("Players").LocalPlayer.PlayerGui.Main.Main.Primary.ImageLabel.ImageTransparency = 0.5
game:GetService("Players").LocalPlayer.PlayerGui.Main.Main.Secondary.ImageLabel.ImageTransparency = 0
HasTool = 3
Humanoid:EquipTool(CRAZZY21)
end
end
end
UIS.InputBegan:Connect(OnInput)
OnInput({KeyCode = Enum.KeyCode.One}) -- Equip Tool on Spawn
-------
game:GetService("Players").LocalPlayer.PlayerGui.Main.GunShop.GunButton2P.MouseButton1Click:Connect(function()
crazygun = true
AK47 = false
end)
game:GetService("Players").LocalPlayer.PlayerGui.Main.GunShop.GunButton1P.MouseButton1Click:Connect(function()
crazygun = false
AK47 = true
end)
you’re setting those boolean values correctly when glicking the guiButton, but you arent doing the if statements you do in OnInput to handle equipping after clicking the guiButton
if AK47 == true then
game:GetService("Players").LocalPlayer.PlayerGui.Main.Main.Primary.BackgroundTransparency = 0.5
game:GetService("Players").LocalPlayer.PlayerGui.Main.Main.Secondary.BackgroundTransparency = 1
game:GetService("Players").LocalPlayer.PlayerGui.Main.Main.Primary.ImageLabel.ImageTransparency = 0
game:GetService("Players").LocalPlayer.PlayerGui.Main.Main.Secondary.ImageLabel.ImageTransparency = 0.5
HasTool = 1 --To Not Equip Tool Multiple Times
Humanoid:EquipTool(tool)
end
if otherGun then
...
end