script.Parent.Parent.Backpack.ChildAdded:connect(function(g) if g.Name ~= "AK47" then g:Destroy() elseif g.Name == "AK47" then print("Right Tool!") end end)
i am trying to make a simple script that Destroys a tool that is not called AK47 but if it is called AK47 it wont delete the tool . but this script will not destroy the tool that is not called AK47. why? please help. output error: ' Something unexpectedly tried to set the parent of 2 to NULL while trying to set the parent of 2. Current parent is Backpack.'
You have to make sure the parent is Backpack. Try this:
script.Parent.Parent.Backpack.ChildAdded:connect(function(g) if g.Name.backpack ~= "AK47" then g:Destroy() elseif g.Name == "AK47" then print("Right Tool!") end end)