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

how do i get 2 baseparts using getchildren() ?

local parent = script.Parent:GetChildren()
    for i = 1,#parent do
    if parent[i]:IsA("BasePart") then

Title ^^

I can't change the (for i = 1) to like 1,2 because i want it to do the same thing to the other one but it doesnt.

1 answer

A Better Way To Do This Is To Use A Generic For.

local parent = script.Parent
for i,v in pairs(parent:GetChildren()) -- "i" in this case is Index, "v" in this case is the object in question.
	if v:IsA("BasePart") then
		--Code
	end
end

Hope This Helped!

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