Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Multiple Part CFrame?

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

1 comment

0

Move in which direction? Up?

2 answers

✓ Accepted answer

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

2 comments

0

Its not working. All it does it goes up one time then stops

0

Fixed it

This discussion is preserved as it was. New answers, comments, and votes are closed.