Below is the working code for the room generator script, my question has to do with the direction the next room faces. Let me explain. The way this simple script works as you can most likely see, is it copies a room from ReplicatedStorage and adds it into a folder in workspace, and places it at the end of the previous room, making it appear for the player to explore. the problem with this script is that while I love having the ability to make random generated rooms, the rooms can only be facing one linear direction. if I make an opening on a different side of a wall, the next room will not spawn in front of the opening. Instead, it will spawn on top and to the side of the previous rooms finishing point, and does not connect. Is there a line or two of code I can make to make the rooms face in the direction the previous rooms exit ended in? so that the rooms are flush together and transition smoothly? Any help is appreciated, I just don't know where to go from here.
local FPD = false -- First Part Down, tells the script when the first section has been placed. local modeltoputin = workspace.RoomFolder local cells = game.ReplicatedStorage:GetChildren() for i, v in pairs(cells) do v.PrimaryPart = v.Start end for y = 1, 4, 1 do local cell = cells[math.random(#cells)]:clone() cell.Parent = modeltoputin if FPD == true then local pos = script.NextPosition.Value cell:MoveTo(pos) script.NextPosition.Value = cell.Finish.CFrame.p end if FPD == false then local pos = workspace.RoomFolder.Begin.Finish.CFrame.p cell:MoveTo(pos) FPD = true script.NextPosition.Value = cell.Finish.CFrame.p end wait(1) end