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

How would I go about moving with :Children()?

Asked by
Resnex 60
10 years ago
wait(1)
script.Parent.Model.children().Parent = script.Parent

How would I move the children of the model to the model that the script's parent is?

4 answers

Log in to vote
1
Answered by 10 years ago

Ah, okay, so let me explain.

First off, ".children()" is incorrect. Use ":GetChilden" to get all Children of the model.

Try this code:

a = script.Parent.Model:GetChildren()

for i,v in pairs(a) do
    if v:IsA("Part") then --selects all children with the classname Part
    v.Position = script.Parent.BrickInThisModel.Position
    else
    return
    end
end
Ad
Log in to vote
0
Answered by 10 years ago

Hmm, try this;

wait(1)
for i, v in pairs(script.Parent.Model:GetChildren())do
if v:IsA("BasePart")then
v.Parent=script.Parent
end
end

Hope this helped!

Log in to vote
0
Answered by 10 years ago
function change(model,parent)
for i,v in pairs(model:GetChildren()) do
if v:IsA("BasePart") then
v.Parent = parent
end
end
end

change(workspace.TigerCaptain,workspace) -- this would essentially decapitate me.
change(workspace.Map,script.Parent) -- this would move all parts from map into script.Parent.
Log in to vote
-1
Answered by
Shawnyg 4330 Trusted Badge of Merit Snack Break Moderation Voter Community Moderator
10 years ago

For this, you'd need to use the GetChildren Method and the for loop to take it into effect..

a = script.Parent.Model:GetChildren() wait(1) for i,v in pairs(a) do a.Parent = script.Parent end

Answer this question