✓ Accepted answer
Make a local script and put this script here. Also put this script in the tool which you are using, which in your case is in the gun.
wait()
EnableBackpackGui = false
Weapon = script.Parent.Name
local player = game:GetService("Players").LocalPlayer
local mouse = player:GetMouse();
local char = player.Character
local tool = player.Backpack:FindFirstChild(""..Weapon.."")
db=1
while wait() do
if char then
game.StarterGui:SetCoreGuiEnabled(2,EnableBackpackGui)
for i,v in ipairs(char:GetChildren()) do
if v.className ~= ""..Weapon.."" then
wait()
if db == 1 then
player.Character.Humanoid:EquipTool(tool)
db=2
end
end
end
script.Parent.Unequipped:connect(function()
db=1
end)
end
end
2 comments
Your script does not look correct.
Simply ensure this code is a LocalScript, and place the tool in StarterPack, it should work I'd hope.