I know about :GetChildren() and :GetDescendants() if you think i mean every object i just cant explain it but i hope what i say below will help. So i want something like :IsA(“PartObject”) that would return true if it is a object that a players character can touch. So like a base part but all of the other stuff.
You should be using a for loop to get all of the children of the folder and then you can check whether if any child is a Basepart, like this:
for i, v in pairs(Folder:GetChildren()) do
if v:IsA("BasePart") then
print(--- print whatever you want)
end
end
local function makeWeld(weldTo)
local weldConst = Instance.new("WeldConstraint",rocket.welds)
weldConst.Part0 = rocket.base
weldConst.Part1 = weldTo
return weldConst
end
for i,v in pairs(rocket.rocket:GetDescendants()) do
makeWeld(v)
end
That is my code but i want to check if its a part that can be welded.
I knew noone would understand what i said
My only guess here is you’re mistaking a BasePart for a regular Part.
Baseparts cover all object types that have collision, including Wedges, Unions, etc, meaning your problem should already be solved.
Example:
local Folder = script.Parent
local Inside = Folder:GetChildren() -- Assigning a local variable is faster.
for _, Search in ipairs(Inside) do
if Search:IsA('BasePart') then
print(Search.Name)
end
end
ipairs
is used for arrays, and GetChildren()
returns an array.
Ok litrally noone understands me.
I have edited my post, I assume that’s what you are looking for.
I looked back and it didnt notify me for some reason but univert solved it by
My only guess here is you’re mistaking a BasePart for a regular Part.
Baseparts cover all object types that have collision, including Wedges, Unions, etc, meaning your problem should already be solved.
Why are you using ipairs? You can use pairs for that and it would work also ipairs is slower than pairs.
You should use ipairs over pairs. GetChildren returns an array, ipairs runs quicker and it’s idiomatic for contiguous arrays.
pairs is designed more for a dictionary where your keys aren’t known (noting that it returns next).
Use cases aside, it’s also good for collaborators and being clear as to what part of the table you’re intending to traverse through. I know when I see ipairs I understand that an array is being iterated over.
Reference: Click here.
Okay understandable gonna start using ipairs over pairs now
Ok me too Again character minimum