Hello, I am trying to make a room generation script. I am trying to make a game inspired by doors called halls.
The script is not working as I expected it to. Its supposed to select a random room then position it to the parent rooms exit door, so the player can go through the door, and go to the next hallway.
I tried :PivotTo and :MoveTo but both dont seem to work.
Here is my code:
function spawn_room(prevroom)
local halls = game.ReplicatedStorage.Halls:GetChildren()
local number = math.random(1, #halls)
local hall = halls[number]
hall.Parent = game.Workspace
hall:PivotTo(CFrame.new(Vector3.new(game.Workspace.Spawned[prevroom].Exit.main_door.Position)))
end
spawn_room('Spawn')
Does anyone know a solution?