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

how can i make a script that deletes a tool from playres backpack?

script.Parent.ChildAdded:connect(function(h)
	local nt = h
	for i,v in pairs(game.Lighting:GetChildren()) do
		if nt.Name ~= v.Name then
			nt:Destroy()
		elseif nt.Name == v.Name then
			print("Right Tool!")
		end
	end
end)

i want this script to delete the new tool if it's name is not found in lighting. this script only deletes the new tool if there is 1 name in lighting if there are more then 1 names in lighting the new tool wont get destroyed even if its name is not found in lighting. please help me.

1 answer

✓ Accepted answer

Try this:

local sp = script.Parent
local lighting = game.Lighting

sp.ChildAdded:connect(function(child)
	local nt = child
	if lighting:FindFirstChild(nt.Name) then
		print("Right Tool!")
	else
		nt:Destroy()
	end
end)

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