Rotation resets when the mouse moves?

localscript that rotates “ghostmodel”:

local player = game.Players.LocalPlayer
local char = player.Character
local space = game.Workspace
local isrotating = false




local ContextActionService = game:GetService("ContextActionService")
function onKeyPress(actionName, userInputState, inputObject)
     if userInputState == Enum.UserInputState.Begin then
       print("began")--begin block of code when button is presses--
isrotating = true

    elseif userInputState == Enum.UserInputState.End then
        print("ended")--block of code for end--
isrotating = false
    end
end

ContextActionService:BindAction("keyPressRotate", onKeyPress, false, Enum.KeyCode.R)



while true do -- block of code above controls code below--
	wait()
	local ghostmodel = script.Parent:FindFirstChild("WeakBlock")
if ghostmodel and isrotating == true then
	local cframe = ghostmodel.PrimaryPart.CFrame -- Current CFrame
	ghostmodel:SetPrimaryPartCFrame(cframe * CFrame.Angles(0, math.rad(0.5), 0))
	end
end

localscript that moves “ghostcopy” to the mouse:

local plr = game.Players.LocalPlayer
local mouse = plr:GetMouse()

ghostcopy = game.ReplicatedFirst.ClientModels.WeakBlock:Clone()
local isequipped = false
script.Parent.Equipped:Connect(function()
	isequipped = true
	ghostcopy.Parent = script.Parent
end)
script.Parent.Unequipped:Connect(function()
	isequipped = false
end)




while true do
	wait()
	if isequipped == true then
		mouse.Move:Connect(function()
			
mouse.TargetFilter = ghostcopy
local cframe = ghostcopy.PrimaryPart.CFrame
local newrot = ghostcopy.PrimaryPart.Orientation.Y

local position = Vector2.new(mouse.X, mouse.Y)

local size = Vector2.new(mouse.ViewSizeX, mouse.ViewSizeY)

local normalizedposition = position / size

ghostcopy.PrimaryPart.CFrame = CFrame.new(mouse.Hit.p)


		end)
		end
end

the model moves around and rotates when R is pressed as it should be. but after rotating the model with R, moving the mouse around resets the rotation of the model back to before it was rotated. I suspect I need to add something to {ghostcopy.PrimaryPart.CFrame = CFrame.new(mouse.Hit.p) } but im not sure what I need to add.

This doesn’t account for the rotation.

Does this create a new connection every 1/30th of a second and is never disconnected? Seems like a massive memory leak.

well that I can fix, but thats beside the point im trying to reach