Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

why wont it delete the tool?

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.'

1 answer

✓ Accepted answer

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)

1 comment

0

same error didnt work

This discussion is preserved as it was. New answers, comments, and votes are closed.