local tool = script.Parent local ply = game.Players.LocalPlayer local character = ply.Character if not character or not character.Parent then character = ply.CharacterAdded:wait() end tool.Parent = character
The script above is a child of my gun and the gun auto equips in studio but not in the game can someone please tell me how to fix this?
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 -- false disables Backpack gui, true enables it. 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
Just put the tool inside "StarterPack" nothing else, You don't need a script just simply drag the tool in the "StarterPack" then it will work.