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

how do i get 2 baseparts using getchildren() ?

Asked by 4 years ago
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

Log in to vote
0
Answered by
Farsalis 369 Moderation Voter
4 years ago
Edited 4 years ago

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!

Ad

Answer this question