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()