I need help with CFrame

I’m trying to make a plot system, My problem: All the houses are facing the same direction not the front
My current code:
for _, plot in pairs(workspace.Plots:GetChildren()) do
if ServerStorage.Houses:FindFirstChild(HouseSelected.Value) then
local HouseToSpawn = ServerStorage.Houses:FindFirstChild(HouseSelected.Value):Clone()
HouseToSpawn.Parent = workspace
HouseToSpawn:SetPrimaryPartCFrame(CFrame.new(plot.Position + Vector3.new(0, 2, 0)))
print(player.Name…" house was spawned in "…plot.Name)
else
error("Could not find house for “…player.Name…”, House name was - "…HouseSelected.Value)
end
end

1 Like

You could just make the house face to the middle, assuming your baseplate is already positioned exactly at the middle 0,0,0 point.

HouseToSpawn:SetPrimaryPartCFrame.new(plot.Position + Vector3.new(0, 2, 0), Vector3.new(0, HouseToSpawn.Position.Y, 0))

Where do you want your houses to face?

House.CFrame = CFrame.lookat(House.Position, Placetolookat.Position)

I haven’t tested this but u can do something like this ^

May I ask, what are the arguments for CFrame.lookat? It’s my first time using this

It seems like you need to set the houses’ orientations to their respective plots’ orientations, so that the houses face their respective plots’ directions.

Arg1 = Position of the part
Arg2 = Position where the part should face

You need to use the plot’s CFrame, otherwise you disregard any of it’s rotation.

for _, plot in pairs(workspace.Plots:GetChildren()) do
	if ServerStorage.Houses:FindFirstChild(HouseSelected.Value) then
		local HouseToSpawn = ServerStorage.Houses:FindFirstChild(HouseSelected.Value):Clone()
		HouseToSpawn.Parent = workspace
		HouseToSpawn:SetPrimaryPartCFrame(plot.CFrame * CFrame.new(0, 2, 0)))
		print(player.Name…" house was spawned in "…plot.Name)
	else
		error("Could not find house for “…player.Name…”, House name was - "…HouseSelected.Value)
	end
end
1 Like

Don’t do this, will cause rotation on to many axises.

then just rotate it on the y axis…

This works on 1 house only, the rest aren’t facing the front

Make sure the plots Lv are facing the intended position

Make sure the front on the plot is on the side that says front. You can figure this out by checking the SurfaceGUI’s Face property.

If the SurfaceGUI doesn’t say Front then change it to Front and rotate the plot accordingly.

I was able to fix it, thanks to everyone who helped!