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

Moving all children to a new parent?

Asked by
PastDays 108
5 years ago

So basically I have a part with all sides covered in Decals, I want to clone all the decals inside and paste them to the Torso and both Legs, What is the easiest and most efficient way of doing this? Would it be using for loop or is there a better way.

1 answer

Log in to vote
1
Answered by 5 years ago
Edited 5 years ago

Ah, well, given your pretty dull question on what you are asking, I'll assume that the part has it's uses with those decals, if it's just a part however that won't be seen/used, I suggest just putting the decals in a folder.

To answer your question, there's a couple of ways of doing it. Me personally, I like to keep things nice and short.

There's a method that not many people use given the, "in pairs," works the exact same way, but if you are trying to use less data, it won't make that big of a difference, but it will be from my personal experience, faster if the scale is larger, for example, 2 thousand parts rather than a few decals, but for practice, I use it always.

for i = 1,#Part:GetChildren() do
       local v = Part:GetChildren()[i]
       local newDecal = v:Clone()
       newDecal.Parent = Player.Torso
end

This works the exact same as it would if I used in pairs, but the difference is I'm merely making a loop, instead of calling the built in function itself.

Doing that, it would clean up your code, and allow you to add more decals into the part itself.

Now, if you want the decals to be cloned differently, for example, some in Torso, some in legs, then I'd suggest making folders and then looping through those folders like I just showed you.

I know this may be a little dull of an answer, feel free to ask questions, however, I can only assume from your short question, so i apologize if I misunderstood.

I am also unsure if you want the shirt and pants to be changed, rather Legs and Torso, so please be more specific.

0
Sorry if i was to vague I was having trouble explaining what i was needing but this worked perfectly! Thank you. PastDays 108 — 5y
Ad

Answer this question