Placement system mouse is on the edge

Does anybody know how to make it be in the center? I have no idea where to even start.

image

function raycast(blacklist)
	local mouse = uis:GetMouseLocation()
	local raycast1 = camera:ViewportPointToRay(mouse.X, mouse.Y)
	local params = RaycastParams.new()
	params.FilterType = Enum.RaycastFilterType.Exclude
	local ovParams = OverlapParams.new()
	ovParams.FilterDescendantsInstances = {}
	ovParams.CollisionGroup = "Default"
	ovParams.FilterType = Enum.RaycastFilterType.Include
	ovParams.MaxParts = 1
	params.FilterDescendantsInstances = {CurrentItem}

	local raycast2 = workspace:Raycast(raycast1.Origin, raycast1.Direction * 50, params, ovParams)
	return raycast2
end

rs.RenderStepped:Connect(function()
	if CurrentItem then
		local result = raycast()
		
		local x = math.floor(result.Position.X)
		local y = math.floor(result.Position.Y + CurrentItem.Size.Y / 2)
		local z = math.floor(result.Position.Z)
		
		CurrentItem.Position = Vector3.new(x,y,z)
	end
end)

I am doing math.floor for it to have snapping, but I don’t think that’s the issue

u can try this code

local screenSize = Vector2.new(game:GetService("GuiService"):GetScreenResolutionX(), game:GetService("GuiService"):GetScreenResolutionY())

rs.RenderStepped:Connect(function()
	if CurrentItem then
		local mouse = uis:GetMouseLocation()
		mouse = Vector2.new(screenSize.X / 2, screenSize.Y / 2) -- Fare imlecinin ekranın ortasına gelmesi
		local raycastResult = raycast()
		
		local x = math.floor(raycastResult.Position.X)
		local y = math.floor(raycastResult.Position.Y + CurrentItem.Size.Y / 2)
		local z = math.floor(raycastResult.Position.Z)
		
		CurrentItem.Position = Vector3.new(x, y, z)
	end
end)