Moving a part every frame does not move orientation

I have been experimenting with moving a part every frame. However, I have found that doing so does not also move the orientation with the part’s position. I want to make the movement act like how tweenservice would.

Code

local speed = 16

game:GetService("RunService").RenderStepped:Connect(function(dt)
	workspace.Part.CFrame = CFrame.new(workspace.Part.Position + (workspace.target.Position - workspace.Part.Position).Unit * speed * dt)
end)

What currently happens:
https://gyazo.com/fde0269d33a93e1082215284cb915006

What should happen
https://gyazo.com/0ba6b7f5b759a0a9d03915569ac863e1

part.CFrame = CFrame.new(vector3Position) * CFrame.Angles(radX, radY, radZ)

thats how to apply orientation to a cframe

https://developer.roblox.com/en-us/api-reference/datatype/CFrame

Right… thanks but I was asking how I could make it smooth, not instant

StartCFrame:Lerp(cframe goal, number alpha)

returns interpolated cframe between start cframe and goal cframe by the fraction alpha.

Check out all CFrame apis here https://developer.roblox.com/en-us/api-reference/datatype/CFrame

This would work however I am trying to get a linear effect

It is a linear effect if you use the start and end and set the cframe to the lerped result. instead of changing the start every time.

1 Like

I found a solution:

local speed = 16

game:GetService("RunService").RenderStepped:Connect(function(dt)
	local orientation = Vector3.new(workspace.Part.Orientation+ (workspace.target.Orientation - workspace.Part.Orientation).Unit * speed * dt)

	workspace.Part.CFrame = CFrame.new(workspace.Part.Position + (workspace.target.Position - workspace.Part.Position).Unit * speed * dt,orientation)
end)