This script was placed inside of the gun, and when I try to run it this error appears: 12:07:19.710 - Something unexpectedly tried to set the parent of Assault Rifle [30] to Player while trying to set the parent of Assault Rifle [30]. Current parent is Backpack. Any Ideas? Here is the full code:
local tool = script.Parent-- Tool local player = script.Parent.Parent -- Player player.Character.Humanoid:EquipTool(tool) tool.CanBeDropped = false function equipAgain() player.Character.Humanoid:EquipTool(tool) end tool.Unequipped:connect(equipAgain)
To equip tool you can just move it into character model, because that's how standart tool equipping works. And your script also must wait untill player character loads in order to equip a tool.
local tool = script.Parent local player = script.Parent.Parent.Parent repeat wait() until player.Character --Wait until player model loads tool.Parent = player.Character --Equipping tool tool.CanBeDropped = false function equipAgain() if tool.Parent == "Backpack" then tool.Parent = player.Character end end tool.Parent.Changed:connect(equipAgain)