What I intend to do, is make a model with a RootPart, that will turn, start moving towards a point/part, while retaining its rotation, and then stop at the destination without rotating. Here's the code that I've got so far:
local tweenservice = game:GetService("TweenService")
local RootPart = script.Parent.RootPart
local target = workspace.Target
-- // Config \\ --
local SPS = 3
function move()
local velocity = (RootPart.Position - target.Position).Magnitude / SPS
local orient = CFrame.new(script.Parent.RootPart.Position,target.Position)
local Orientation = {CFrame = orient}
local dest = CFrame.new(target.Position.X,RootPart.Position.Y,target.Position.Z) * CFrame.Angles(0,0,0)
local Destination = {CFrame = dest}
local move = tweenservice:Create(RootPart,TweenInfo.new(velocity,Enum.EasingStyle.Sine),Destination)
local rotate = tweenservice:Create(RootPart,TweenInfo.new(1,Enum.EasingStyle.Sine),Orientation)
rotate:Play()
rotate.Completed:Connect(function()
local newMatrices = RootPart.CFrame:GetComponents()
wait(.1)
move:Play()
end)
end
local debounce = false
workspace.Target.Changed:Connect(function()
if not debounce then
debounce = true
print("moving")
wait(2)
move()
debounce = false
end
end)
It works right up until the model starts moving, and the RootPart's orientation starts tweening towards 0,0,0.
I suspect this has to do with the fact since I am not setting the part's rotational CFrame, it resets it back to 0,0,0, however I do not know how I would go about tweening it in a way where it either keeps the rotation, or it doesn't utilise the rotation parameters.
Any help and resources are greatly appreciated!
