Attempt to index nil with "PrimaryPart"

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

I Used this placement system;

image

You need to put the primary part from your model object in properties.

Actually, with this error, the issue is model is not defined


@Chaos_milo how are you calling the function?

Fixed it, (Forgot to anchor the Part for the placement system)
Ugh.
Thanks Anyway!

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.