Im trying to make a script that takes tools that have the names Listed in Tool_Names but the issue is no tools get taken. Nothing comes up in output so I think the issue is with the local Tool_Names or the way I used the local Tool_Names in the script
local Tool_Names = {
"Headlock","Rush","BodySlam"
}
for _, tools in pairs(plr.Backpack:GetChildren()) do
if tools.Name == Tool_Names then
tools.Parent = plr.TS
--// plr.TS is a folder inside the player to store tools
end
end
You’d want to use table.find since you’re checking if the name of the tool is in the Tool_Names list.
local Tool_Names = {
"Headlock","Rush","BodySlam"
}
for _, tools in pairs(plr.Backpack:GetChildren()) do
if table.find(Tool_Names, tools.Name) then -- if table.find doesn't find it, it will return nil and the check doesn't pass
tools.Parent = plr.TS
end
end
The way you were doing it before was comparing tools.Name to the Tools_Name list:
-- you were doing:
if <string> == <table> then ...