Dungeon Generator CFrame issue

Currently I am trying to make a doorway face a empty doorway

image

I want the model to rotate so the yellow node is facing the center

The Red block is the model’s PrimaryPart and I’m changing the rotation using SetPrimaryPartCFrame

this is the code where I try to rotate it


NeededRoom:SetPrimaryPartCFrame(CFrame.new(RoomNodes[i].Parent.Parent.PrimaryPart.Position + (RoomNodes[i].CFrame.lookVector * 50)), RoomNodes[i].Position)

NeededRoom.Nodes[NeededType].BrickColor = BrickColor.new("Bright yellow")

RoomNodes[i].Parent.Parent.PrimaryPart.Position is the Red block in the center of the middle room

RoomNodes[i] is the node is the green node in the empty hallway of the center room that is facing the closest room

NeededRoom is the room that is supposed to be facing towards the center

NeededRoom PrimaryPart is the NeededRoom’s Red Cube

how one room is
image

how it should be

image

5 Likes

Could you elaborate a little more on what “the center” is? Also, in your second and third screenshots, which room is NeededRoom and which red part is RoomNodes[i]?

1 Like

I just figured it out, so I don’t need help anymore, but thanks

1 Like

Kindly post a detailed reply on what the solution was and not

Other people may run into this issue and you can help by posting what specifically the solution was.

3 Likes

A is Start Room B is Room that is going to be connected

each room has a node for every door that is open

I change Room B’s Primary Part’s Orientation to the Orientation of Room B’s Node that is going to be connected to Room A

I then set the Primary Part CFrame of Room B to be 50 studs(size of the rooms) away from Room A

after that I set the PrimaryPart again to face in the direction of Room A’s Primary Part

repeat

7 Likes

how did u get it so that another room wont be placed in the a position where there is already a room?