Room Generation Script not working as expected

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?

What does it currently do? “not working as expected” gives zero information.

CFrame.new(Vector3.new(game.Workspace.Spawned[prevroom].Exit.main_door.Position)))
Why are you using Vector3.new on a Vector3, and then using CFrame.new on that Vector3?

local function spawn_room(prevroom)
	local halls = game.ReplicatedStorage.Halls:GetChildren()
	local number = math.random(1, #halls)
	local hall = halls[number]
	hall:PivotTo(workspace.Spawned[prevroom].Exit.main_door.CFrame)
	hall.Parent = workspace
end
spawn_room('Spawn')

its in the wrong position and I tried Cframe but now it now spawns inside of the hall
(Originally it was wrong position)