How to find a child by name followed by number

Basically, I’m making a chunk load system and I want to get all the chunks (If there are 16 chunks, it gets the 16 and not any other number).
Example:
Local c1 = game.Workspace.Folder:FindFirstChild(“Chunk”… 7)
And get them one by one, cloning them, and putting them in workspace.
How can I achieve that?

1 Like

You think you could try out a pseudo code example of what you want to try to do?

e.g.

if there are 5 chunks, then
    unload chunks 1 to 4
1 Like

what

do you want to get its index (order in table) or numbers on its name?

1 Like

you can use a loop to iterate through the numbers and find each chunk
, here’s a script

local folder = -- refer to this folder ( Ensure that the chunks are children of it )
local chunks = 16 
for i = 1, chunks do 
local chunkName = " whateveryou want ".. i
local chunk = Folder:FindFirstChild(chunkName)
if chunk then 
local clone = chunk:clone()
clone.Parent = game.Workspace 
else 
print("Not found ") -- debugging you can adjust this 
end
end


we aint on scratch here bud :skull:

(stuff)

2 Likes

no, i just have trouble understanding what he wants to get done. plus, pseudo code is used so often, and it’s not specially locked to beginner level programmers

2 Likes

If i’m understanding correctly, he wants to have his chunks like this, " chunk1 ", " chunck2 " all way to 16

1 Like

here you go

hope this helps em-B6BA38E0FE71CA2-48-sexy

1 Like

I don’t recommend asking CHATGPT for a script, lol.

2 Likes

i also dont recommend stealing code from chatgpt :slight_smile:

1 Like

Can’t you use a for loop + tables?

local c1 = game.Workspace.Folder:GetChildren()

for index, chunk in c1 do
local clonedchunk = chunk:Clone()
clonedchunk.Parent = workspace
end
1 Like

Wow I got two solutions at the same time. Crazy.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.