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

Why is this not working?

This script is supposed to remove anything with the name of "BC" and "KorbloxianKnight"

debounce = false
script.Parent.Touched:connect(function(hit)
	if not debounce then
		debounce = true
		for _,v in pairs(workspace:GetChildren())do
		if v.Name == "BC" and v.Name == "FastRobloxian" then
			game.Debris:AddItem(v,0)
		end
		end
	end
	wait(5)
	debounce = false
end)

1 answer

✓ Accepted answer

You Problem

When you try to determine the current index's name on line 6 then you're using an and statement. The object's name can't be "BC" AND "FastRobloxian" - it can only be one or the other.

So, rather than using an and statement, use an or statement.


Code

local debounce = false

script.Parent.Touched:connect(function(hit)
	if not debounce then
		debounce = true
		for _,v in pairs(workspace:GetChildren())do
			if v.Name == "BC" or v.Name == "FastRobloxian" then
				game.Debris:AddItem(v,0)
			end
		end
	end
	wait(5)
	debounce = false
end)

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