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

Multiple Part CFrame?

Asked by 9 years ago

Im trying to move all parts in a models CFrame the same distance but keeping the model together

parts = script.Parent:GetChildren()
for i=1,10 do
    parts.CFrame = parts.CFrame * CFrame.new(0,0.1,0)
    wait(0.01)
end
0
Move in which direction? Up? BlueTaslem 18071 — 9y

2 answers

Log in to vote
2
Answered by
BlueTaslem 18071 Moderation Voter Administrator Community Moderator Super Administrator
9 years ago

When you multiply by a CFrame, that moves relative to how the part is facing. That's probably not what you want in a model, since the "model" doesn't have any meaningful collective direction.

If you want it to go up, then you should add a Vector3.


parts is a list of the children. Lists don't have CFrames; elements (in this case, probably Parts) of the list do. Thus we have to do something to each element of the list. We can use a general for loop for that:

for _, part in pairs(parts) do
    if part:IsA("BasePart") then
        -- Just to be sure that only Parts are in the model
        part.CFrame = part.CFrame + Vector3.new(0, 0.1, 0)
    end
end

If we want to do this repeatedly (probably you do) you would just encase it in a loop as you had:

for i = 1, 10 do
    for _, part in pairs(parts) do
        .... -- From above
    end
    wait(0.1)
    -- Must wait at least .03 seconds; .01 is too few
end
0
Its not working. All it does it goes up one time then stops Timster111 25 — 9y
0
Fixed it Timster111 25 — 9y
Ad
Log in to vote
-1
Answered by 9 years ago

Not possible in less you find a plug in for it.

Answer this question