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 list 2 or more Childs(FindFirstChild)?

very easy to solve, i just got back into lua.

local Findit =  (script.Parent.Parent:FindFirstChild("LegTrue")),(script.Parent.Parent:FindFirstChild"TorsoTrue")

4 comments

0

Weird Glitch going on, Top line (my words) aren't part of the script, Sorry!

0

two different variables?? why are you trying to combine them?

0

and it wasn't a glitch. you put four spaces before your description, so it considered it a code block

0

@Gey4Jesus69, yes I am trying to use one (local) variable to collect two of these parts (TorsoTrue, As well as LegTrue)

1 answer

✓ Accepted answer

Just store them in two separate variables:

local Leg = script.Parent.Parent:FindFirstChild("LegTrue")
local Torso = script.Parent.Parent:FindFirstChild("TorsoTrue")

If you truly need them in one place, you can store them in a table, like so:

local Parts = {}

local Leg = script.Parent.Parent:FindFirstChild("LegTrue")
local Torso = script.Parent.Parent:FindFirstChild("TorsoTrue")

if Leg and Torso then
	table.insert(Parts,Leg)
	table.insert(Parts,Torso)
end

Also note that parentheses do not have to wrap statements, like in Javascript and similar languages. For example, in if statements, you do not have to wrap the conditions.

in lua

if condition then

end

in Javascript

if (condition) {

}

2 comments

1

Thank you so much, trying to figure out how I can lower the amount of lines in my code/ make it look nicer! thanks so much

1

https://gyazo.com/db5945297faf59c9066db608691ecee8 Might be a stupid project but u helped :)

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