Incorrect rotation of object along Y axis

The problem is that i need the object to rotate 90 degrees only on the Y axis. I tried using CFrame:ToOrientation() and CFrame:ToEulerAngles() methods, but they forced the object to rotate on the X or Z axis. Now I use CFrame.Rotation, but it doesn’t allow the object to rotate.

if direction.Z~=0 then
			runService.Heartbeat:Connect(function(deltaTime)
				if rotationActive then
					local currentCFrame=arrow.PrimaryPart.CFrame
					local newCFrame=currentCFrame*CFrame.Angles(0,math.rad(90)*deltaTime,0)
					currentCFrame=newCFrame
				end
			end)
		end
		
		local targetCFrame=CFrame.new(nextPart.Position)*arrow.PrimaryPart.CFrame.Rotation
		local tween=tweenService:Create(arrow.PrimaryPart,tweenInfo,{CFrame=targetCFrame})


Is this what you’re trying to do? In that case you need to set the newCFrame to your actual primarypart’s CFrame:

runService.Heartbeat:Connect(function(deltaTime)
	if rotationActive then
		local currentCFrame = arrow.PrimaryPart.CFrame
		local newCFrame=currentCFrame*CFrame.Angles(0,math.rad(90)*deltaTime,0)
		arrow.PrimaryPart.CFrame=newCFrame
	end
end)

If you’re looking to move the object using the tween while it rotates then you should set the tween to change the position rather than the whole CFrame as then the rotation won’t work:

local tween=tweenService:Create(part,tweeninfo,{Position = nextPart.Position})
tween:Play()

Not exactly what I was looking for. I need the object to rotate only once during the animation and change orientation on nextPart.

If you want it to rotate only once then is there a reason you’re using Heartbeat instead of a tween?

I don’t understand what you mean by this. Could you give a little more information?

It will be hard to explain but you almost helped me anyway. I will try to figure it out myself from now on.

2 Likes

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