I get this error on the function:
Attempt to index nil with “PrimaryPart”
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