Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

how do i use FindFirstChild() twice? [ anwsered ]

so basically ive got a terrain generation script, the terrain is split up into chunk folders and i need to access a part from a chunk the code goes something like

Land:FindFirstChild(hpos..""..wpos..""..lpos):FindFirstChild(h..""..w..""..l)

just doing

Land:FindFirstChild(hpos..""..wpos..""..lpos) returns a value and ive double and triple cheaked it should work but it returns nil ?

help? its kinda needed for my game given the millions of parts when i generate the terrain fully

2 answers

✓ Accepted answer

From what I’ve understood you can try to Use 2 variables

local chunk1 = land:FindFirstChild(name of the chunk)
local objectinchunk = chunk1:FindFirstChild(name of the object)

Obviously you need to format it correctly and change the variables to whatever you want but that’s the basic idea.

5 comments

0

sorry thats exactly what i did it returns nul

1

Try and check the placement and where you put the Chunks and folders as firstchild only applies to the immediate child not anything under that, which would be done using descendants

0

ok thx

1

Can you mark me as the answer please

0

i dont know how i would have already

I believe in this case, what you are doing has an alternative:

local Child = Land[hpos.." "..wpos..""..lpos][h.." "..w..""..l]

I believe that should work, if it doesn't then looping is another way..

Also, maybe it is returning nil because there is no gap between "".

Also yes, what Glacitron said should work.

This discussion is preserved as it was. New answers, comments, and votes are closed.