Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

why wont it delete the tool?

Asked by
MHaven1 159
7 years ago
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

Log in to vote
1
Answered by
s_21 74
7 years ago

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)
0
same error didnt work MHaven1 159 — 7y
Ad

Answer this question