Local script acts different than server script

Ok , so im doing building system, specifically a block that is visible to local player only showing where the block will be placed but i have problems with position alignment

I have server script that place block when remote event fired so i took and copy piece of code that does position and rotation alignment and pasted it in local script but im having troubles, its offset, and offset is bigger when parts are more rotated

on the server script, it works normally with no errors and offsets. Vaules from the local and the server script are the same. here is the piece of code that does it

if ray then
			if table.find(ray.Instance:GetTags(), "Build") then
				part.Position = (part.CFrame:VectorToWorldSpace(ray.Normal) * 2 + ray.Instance.Position)
				print(part.CFrame:VectorToWorldSpace(ray.Normal))
				part.Rotation = ray.Instance.Rotation
				if table.find(part:GetTags(), "Interactive") then
					part.CFrame = part.CFrame * CFrame.Angles(math.rad(X), math.rad(Y), math.rad(Z))
				end
			else
				part.Position = Vector3.new(roundToNumber(ray.Position.X,1.999), roundToNumber(ray.Position.Y,1.999), roundToNumber(ray.Position.Z,1.999))
			end
		end

I don’t really understand this code but I made a custom one:

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

local block = --your block

mouse.Move:Connect(function()
    local mousePos = mouse.Hit.Position
    local halfSize = block.Size.Y / 2

    block.Position = mousePos + Vector3.new(0, halfSize, 0)
end)

something like this probably