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

inserting a lot of data in an array?

Asked by 8 years ago

hello thanks for lending me your time, I was wondering if it was possible to insert a whole segment of an array into another one given a certain condition. I can't figure out why this isnt working:

local parts = map:GetChildren()
local mapparts = {}

for _, p in ipairs (parts) do
    if p.Name == "mappiece" then
    table.insert (mapparts, p)
    end
end

i dont know why it only inserts 1 value into the table 'mapparts', could anyone help me out? thanks! (table parts has a lot of parts named mappiece)

1 answer

Log in to vote
0
Answered by 8 years ago

ok sorry im stupid, i did it wrong, but anyways, if anyone would like to know how i did it for future reference;

local parts = map:GetChildren()
local mapparts = {}

function sorter(part)
        if part.Name == "mappiece" then
            table.insert(mapparts,part)
        end
    end

for _, wotowot in ipairs (parts) do
    sorter(wotowot)
end
0
close the question please UniversalDreams 205 — 8y
Ad

Answer this question