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

why does it only read the last item ?

Asked by 9 years ago

its only reading test and not LavaSword

local names = {"LavaSword","test"}
for i = 1,#names do
function clean()
        if Player.Backpack:FindFirstChild(names[i],true) then
            Player.Backpack:FindFirstChild(names[i],true):remove()
        end
end
end

1 answer

Log in to vote
0
Answered by
adark 5487 Badge of Merit Moderation Voter Community Moderator
9 years ago

I'm not actually sure what you're trying to do here with that clean function.

I assume you meant to do this:

local names = {"LavaSword","test"}
function clean()
    Player.Character.Humanoid:UnequipTools() --forcefully unequips all Tools, so you don't miss any in the loop.
    for i = 1,#names do
            if Player.Backpack:FindFirstChild(names[i],true) then
                Player.Backpack:FindFirstChild(names[i],true):remove()
            end
    end
end

clean()
Ad

Answer this question