How to make this i, v in pairs weld loop work?

And just to clarify, if I want one specific part to be the one object that every other object is welded to, I place that first in the code you provided?

EDIT: Nevermind I see what you mean, that worked like a charm, is it fine if I use this code for my game btw?

1 Like

Here’s an example.

local Descendants = game.Workspace.ExampleModel:GetDescendants()

for i = 1, #Descendants do
if Descendants[i].Name == "ExamplePart" or Descendants[i].Name == "ExampleMesh" then
local Cotton = Instance.new("Part")
Cotton.Parent = Descendants[i]
Cotton.Shape = Enum.PartType.Ball
Cotton.Anchored = true
Cotton.Position = Cotton.Parent.Position+Vector3.new(0, 2, 0)
end
end

(This was meant for way earlier, but my internet decided to be trash.)

2 Likes

Also, an i = 1, # loop is perfect for this. I know because I’ve used this exact method when it came to parts. And it worked fine.

3 Likes

Ahh that’s great to know, never knew how those worked, thank you very much!

1 Like

Ah, got it. Thank you for the example.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.