Problem with adding value to Mouse Y hit

I want to make building system, but I keep getting errror below, it is part when I try to make work of placing on all surfaces correct. By correct I mean that blocks were keeping to appear inside of other blocks.

ADDITIONAL: I use studio beta newer and faster lua.

17:53:45.964 - Players.japietru2004.PlayerGui.ItemGui.AllControl:159: attempt to perform arithmetic (add) on number and userdata

My code is her - part what have errors has comment near it “ERROR is happening in this line”.


local plr = game.Players.LocalPlayer
local char = plr.Character or plr.CharacterAdded:wait()
local mouse = plr:GetMouse()

local item = script.Parent.Item
local delete = script.Parent.Delete

local xn = 0
local yn = 0
local zn = 0



function FaceCheck(FaceV,GType,item)
	local xp = item.Configuration["x+"]
	local yp = item.Configuration["y+"]
	local zp = item.Configuration["z+"]
	local xl = 0
	local yl = 0
	local zl = 0
	if GType=="LargeGrid" then
		if FaceV.X==1 then
			xl = xp
		elseif FaceV.X==-1 then
			xl = item.Main.Size.X - xp
		else
			xl = 0
		end
		if FaceV.Y==1 then
			yl = yp
		elseif FaceV.Y==-1 then
			yl = item.Main.Size.Y - yp
		else
			yl = 0
		end
		if FaceV.Z==1 then
			zl = zp
		elseif FaceV.Z==-1 then
			zl = item.Main.Size.Z - zp
		else
			zl = 0
		end
	elseif GType=="SmallGrid" then
		if FaceV.X==1 then
			xl = xp
		elseif FaceV.X==-1 then
			xl = item.Main.Size.X - xp
		else
			xl = 0
		end
		if FaceV.Y==1 then
			yl = yp
		elseif FaceV.Y==-1 then
			yl = item.Main.Size.Y - yp
		else
			yl = 0
		end
		if FaceV.Z==1 then
			zl = zp
		elseif FaceV.Z==-1 then
			zl = item.Main.Size.Z - zp
		else
			zl = 0
		end
	end
	return xl,yl,zl
end

mouse.Move:connect(function()
	local pos = mouse.hit.p
	if item.Value ~= "" and delete.Value == false then
		if char:FindFirstChild(item.Value) then
			local i = char[item.Value]
			for _,v in pairs (i:GetChildren()) do
				if v:IsA("Part") then
					v.CanCollide = false
				end
			end
			local r = script.Parent.Rot.Value
			--mouse.TargetFilter = mouse.hit
			--local target = mouse.Target
			local face = mouse.TargetSurface
			--local part = mouse.hit
			xn,yn,zn=FaceCheck(Vector3.FromNormalId(face),script.Parent.GridType.Value,i)
			print(pos.X)
			local newMouX = pos.X+xn
			local newMouY = pos.Y+yn --ERROR is happening in this line
			local newMouZ = pos.Z+zn
			print(newMouX.." | "..newMouY.." | "..newMouZ)
			
			
			--i:SetPrimaryPartCFrame(CFrame.new(target.Position + (Vector3.FromNormalId(face) * i.Main.Size)))
			 
			i:SetPrimaryPartCFrame(CFrame.new(Vector3.new(math.floor(newMouX), math.floor(newMouY+i.Main.Size.Y/2)+.5, math.floor(newMouZ))) * CFrame.Angles(math.rad(r.X),math.rad(r.Y),math.rad(r.Z)))
			--* i.Main.Size)/2 +(Vector3.FromNormalId(face))
			--math.rad(r.X),math.rad(r.Y),math.rad(r.Z)
			--i:SetPrimaryPartCFrame(i.PrimaryPart.Position * CFrame.Angles(math.rad(r.X),math.rad(r.Y),math.rad(r.Z))) --CFrame.Angles(r.X,r.Y,r.Z)
			script.Parent.Pos.Value = Vector3.new(math.floor(pos.X), math.floor(pos.Y+i.Main.Size.Y/2)+.5, math.floor(pos.Z))
		end
	end
end)