How do I make a part welded via motor6d not rotate around the part it's welded to?

Is there any way I can make it so a part welded to a player via Motor6d doesn’t rotate around the character? My game is 2D, and I want it to only move with the player on the x-axis in terms of position, and not rotate when the player turns. When the player is facing right, the object is visible from the 2D perspective. However, when the player is facing left, it is behind the camera. Is there any way I can make it not rotate and only move with the player whenever they move around on the x-axis?

Video for reference:

Yes, but im assuming that you want it to find the closest angle to and then move the part behind you based on that. To do that get rid of the weld, and try something like this:


local part = workspace.PartFollowing
local root = humanoidRootPartHere
local camera = workspace.CurrentCamera

RS.Heartbeat:Connect(function() -- if its in a server script, use a BodyPosition, and if its in a local script, keep this code all the same here
    local camLeftVector = camera.CFrame:VectorToWorldSpace(Vector3.new(-1, 0, 0))
    local camRightVector = camera.CFrame:VectorToWorldSpace(Vector3.new(1, 0, 0))
    
    local rootLookVector = root.CFrame.LookVector
    local isCloserToRight = rootLookVector:Dot(camRightVector) > rootLookVector:Dot(camLeftVector)

    part.Position = part.Position:Lerp(root.Position + (isCloserToRight and camRightVector or camLeftVector) * 10, 0.5)
end)
2 Likes