CFrame tweening issue?

So im trying to cframe a part over, then move it back, but when it moves back its slightly off from the original? Im only moving the X position by 5 and then back another 5, so it should end up back in the same place but it doesn’t, any help?

Position = Vector3.new(part.CFrame.X + 5 , part.CFrame.Y, part.CFrame.Z);

		Position = Vector3.new(part.CFrame.X - 5 , part.CFrame.Y, part.CFrame.Z);

Are you running two separate Tweens? and is the part anchored or under any other constraints?
To move it back and forth there is the option to set reverses? to true.

The issue with your code is that you’re creating two Vector3 objects but not actually applying them to the part’s CFrame.

Instead of creating two separate Vector3 objects, you can directly modify the part’s CFrame using the CFrame.new() method. Here’s an example of how you can do this:

local originalCFrame = part.CFrame
local newPosition = originalCFrame + Vector3.new(5, 0, 0)
local returnPosition = originalCFrame - Vector3.new(5, 0, 0)

-- Move the part to the new position
part.CFrame = CFrame.new(newPosition)

-- Wait for a few seconds
wait(2)

-- Move the part back to the original position
part.CFrame = originalCFrame

In this example, we first save the original CFrame of the part . We then calculate the new position by adding Vector3.new(5, 0, 0) to the original CFrame , and calculate the return position by subtracting Vector3.new(5, 0, 0) from the original CFrame .
By directly modifying the CFrame of the part , we ensure that the orientation of the part is preserved when moving it back and forth.

From what I can tell it’s supposed to go back to the original position, exactly where it was before it was teleported. In the example script you provided (and in the script from the OP) the returning position is the original one but with 5 subtracted from the X component. That’s why it’s not going to the original position, but rather further than it.

That is correct, I did not include the original position.
The code has been updated to support that.

Why are you using CFrame for this though? Use Part.Position

This is for the first code

The OP’s code is tweening the Position and not the CFrame. The title could be mistakenly written as CFrame instead of Position.