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

Why is this not working?

Asked by 8 years ago

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

Log in to vote
3
Answered by
Goulstem 8144 Badge of Merit Moderation Voter Administrator Community Moderator
8 years ago

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)
Ad

Answer this question