Help with parts moving on different axis

I have made a script to make a group of parts come towards you all at once however some of the parts move on a completely different axis and i don’t know how to fix this any help appreciated thanks.

local s = script.Parent


for _, i in pairs(s:GetDescendants()) do
	if i:IsA("BasePart")then
		coroutine.wrap(function()
			for d = 0,10,0.01 do
				i.CFrame = i.CFrame * CFrame.new(-d,0,0) 
				wait(0.01)
			end
		end)()
	end
end
		
			

It’s because you are moving each Part on it’s own axis, not the world axis.

Object and World Space | Roblox Creator Documentation

So what script should i use, this link makes no sense to me

local s = script.Parent

for _, i in pairs(s:GetDescendants()) do
	if i:IsA("BasePart")then
		coroutine.wrap(function()
			for d = 0,10,0.01 do
				i.CFrame = i.CFrame * i.CFrame:ToObjectSpace(CFrame.new(-d,0,0))
				wait(0.01)
			end
		end)()
	end
end

although that is equivalent to the simpler

local s = script.Parent

for _, i in pairs(s:GetDescendants()) do
	if i:IsA("BasePart")then
		coroutine.wrap(function()
			for d = 0,10,0.01 do
				i.CFrame = i.CFrame + Vector3.new(-d,0,0)
				wait(0.01)
			end
		end)()
	end
end

so probably just use that.

2 Likes

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