Setting position of house model based off a part

So basically, I have a some reference parts to help spawn a base. The problem is, I don’t know how to set the position of the base based off the parts. I am trying to make it so that the front of the base (basically the path, is connected to said part and the base is not in the ground.

What I want

What I’m getting

Code:

function BaseService.new(owner: Player)
	local self = setmetatable({}, BaseService)
	self.Owner = owner
	self.Temp = BaseTemp:Clone()
	print("Cloned")
	self.Temp.Parent = Bases
	print("Set Parent")
	SetBasePosition(self.Temp)
	return self
end

function BaseService:SetDetails()
	self.Temp:SetAttribute("Owner", self.Owner.Name)
	print("Set Owner")
	self.Temp:SetAttribute("OwnerID", self.Owner.UserId)
	print("Set Owner ID")
end

function SetBasePosition(base: Model)
	local baseSpawn = BaseSpawns:GetChildren()[math.random(1, #BaseSpawns:GetChildren())]
	local baseSpawnCF = baseSpawn.CFrame

	local baseSize = base:GetExtentsSize()
	local offset = baseSpawnCF.LookVector * (baseSize.Z / 2)
	local NewCFrame = CFrame.new(baseSpawnCF.Position - offset)

	base:PivotTo(NewCFrame)
end
1 Like

If the base is a model, you could’ve just set both the base and part’s pivot to the bottom of their faces, use Part:GetPivot() --cframe to get the part’s pivot, and then use Base:PivotTo(cframe) --pivot of the part.

doesn’t that just get the cframe of the part? I already set the cframe and it is the same result. Yes the base is a model

:GetPivot() returns a CFrame of a PVObject’s pivot.

yeah so that wouldn’t help. I’m trying to make the base “connect” to the part basically. Like the end of the path is connecting to the part and the base is not in the ground.

In that case, just set the both the model’s and part’s pivot to its front bottom.

Is there a method to do that? like a specific function or

Studio > Model tab > Pivot tool

is it called Align tool? I dont see pivot

If you want the pivot to be customizable via a script, use the Model.PrimaryPart property.