So i made this script :

local moving



local originalLeft = script.Parent.Left.PrimaryPart.CFrame
local originalRight = script.Parent.Right.PrimaryPart.CFrame


function move()
	script.Parent.Sound:play()	
	for i=1,30 do
		script.Parent.Left:SetPrimaryPartCFrame(originalLeft * CFrame.new(-2*(i/30),0,-1*(i/30)))
		script.Parent.Right:SetPrimaryPartCFrame(originalRight * CFrame.new(2*(i/30),0,1*(i/30)))
		script.Parent.Left:SetPrimaryPartCFrame(originalLeft * CFrame.Angles(0,-0.5*(i/30),0))
		script.Parent.Right:SetPrimaryPartCFrame(originalRight * CFrame.Angles(0,-0.5*(i/30),0))
		wait()
	end
	
	wait(4)
	script.Parent.Sound:play()
	for i=29,0,-1 do
		script.Parent.Left:SetPrimaryPartCFrame(originalLeft * CFrame.new(-2*(i/30),0,-1*(i/30)))
		script.Parent.Right:SetPrimaryPartCFrame(originalRight * CFrame.new(2*(i/30),0,1*(i/30)))
		script.Parent.Left:SetPrimaryPartCFrame(originalLeft * CFrame.Angles(0,-0.5*(i/30),0))
		script.Parent.Right:SetPrimaryPartCFrame(originalRight * CFrame.Angles(0,-0.5*(i/30),0))
		wait()
	end
	
	wait(1)
end




script.Parent.Collision.Touched:connect(function(hit)
	if not moving then
		moving = true
		move()
		moving = false
	end
end)

Before i added the CFrame.Angles, The CFrame.new would work perfectly and objects would move as intended, But then i added the CFrame.Angles and the objects stopped moving and only the rotation worked. Meaning that i cant get the objects to both move and rotate at the same time. Am i doing something wrong? Any help would be appreciated.

1 comment

0

originalLeft and originalRight are constant values (ie they're not being updated). Because of this, the first 2 statements in your for loops aren't doing anything since you're overwriting it with the latter 2.