Model orientation is lost on part placement function

I got a function that moves a model that the player is placing when the mouse moves, however the model orientation is lost whenever the model is moved, how could this be fixed?

			if placingblock then
				local ignoreList = {toplace, plr.Character}
				local mouseRay = mouse.UnitRay
				local newRay =, mouseRay.Direction.unit * 35)
				target, pos, norm = workspace:FindPartOnRayWithIgnoreList(newRay, ignoreList)
				local RX, RY, RZ = toplace.PrimaryPart.CFrame:ToOrientation()
				local endpos =,math.floor(pos.Y),math.floor(pos.Z)) + (norm * toplace.PrimaryPart.Size * .5)


1 Like

CFrames have two arguments, positional and rotational. You’re only setting the positional, so the rotation is set back to default (negative Z axis, I believe).

Get the PrimaryPart’s rotation with local lookVector = toplace.PrimaryPart.CFrame.LookVector, and then set the CFrame as toplace:SetPrimaryPartCFrame(, lookVector))

I assume that would work if I just used SetPrimaryPartCFrame with the mouse.Hit, however my method of positioning the model seems to break your method and i cannot figure out why exactly…


1 Like

After struggling with this issue for 2 weeks, i finally came up with a simple good solution

local rotX,rotY,rotZ =  toplace.PrimaryPart.CFrame:ToEulerAnglesXYZ()
toplace:SetPrimaryPartCFrame( * CFrame.fromEulerAnglesXYZ(rotX,rotY,rotZ))

This just shows how bad I am with CFrames X(