Wall Glitching with EgoMoose Furniture System

Hello fellow developers. I’m having some problem with EgoMoose furniture system. Here’s proof:
robloxapp-20210910-1641273.wmv (544.5 KB) Sorry you have to download it. I assume nobody has asked this question because no one have used his furniture system like this. I am unsure what is the problem, what is causing it, and how to solve it. If you have any ideas how to fix this I would greatly appreciate it. Also here is the script:

--Module script
function Placement:CalcCanvas()
	local canvasSize = self.CanvasPart.Size

	local up = Vector3.new(0, 1, 0)
	local back = -Vector3.FromNormalId(self.Surface)

	local dot = back:Dot(Vector3.new(0, 1, 0))
	local axis = (math.abs(dot) == 1) and Vector3.new(-dot, 0, 0) or up

	local right = CFrame.fromAxisAngle(axis, math.pi/2) * back
	local top = back:Cross(right).unit

	local cf = self.CanvasPart.CFrame * CFrame.fromMatrix(-back*canvasSize/2, right, top, back)
	local size = Vector2.new((canvasSize * right).magnitude, (canvasSize * top).magnitude)

	return cf, size
end

function Placement:CalcPlacementCFrame(model, position, rotation)
	local cf, size = self:CalcCanvas()

	local modelSize = CFrame.fromEulerAnglesYXZ(0, rotation, 0) * model.PrimaryPart.Size
	modelSize = Vector3.new(math.abs(modelSize.x), math.abs(modelSize.y), math.abs(modelSize.z))

	local lpos = cf:pointToObjectSpace(position);
	local size2 = (size - Vector2.new(modelSize.x, modelSize.z))/2
	local x = math.clamp(lpos.x, -size2.x, size2.x);
	local y = math.clamp(lpos.y, -size2.y, size2.y);

	local g = self.GridUnit
	
	if (g > 0) then
		x = math.sign(x)*((math.abs(x) - math.abs(x) % g) + (size2.x % g))
		y = math.sign(y)*((math.abs(y) - math.abs(y) % g) + (size2.y % g))
	end

	return cf * CFrame.new(x, y, -modelSize.y/2) * CFrame.Angles(-math.pi/2, rotation, 0)
end

-- Local script
game:GetService("RunService").RenderStepped:Connect(function(dt)
	if model == nil then return end

	local cf = placement:CalcPlacementCFrame(model, mouse.Hit.p, rotation)

	model:SetPrimaryPartCFrame(cf)
	placement:isColliding(model)
end)

Set Mouse.TargetFilter to the model.

2 Likes

Oh um… thank you that was a really easy fix.

Just FYI if you just drag the video file into your post as you’re writing it, it should just embed itself automatically.