What is wrong with my script?

Im making a template but my script isint working.
It makes randomly generated rooms but after it sets the first it doesent change position.

local startpos = game.Workspace:WaitForChild("Enterance").Doors.Exit.CFrame
db = false
script.Configuration.roomsGenerated.Changed:Connect(function()
	if script.Configuration.roomsGenerated.Value < 1 then
		db = true
	end
end)
while true do
	wait()
	if db == false then
		db = true
		script.Configuration.roomsGenerated.Value -= 1
		local mathRandom = math.random(1, script.Configuration.roomsNumber.Value)
		local roomNew = game.ReplicatedStorage.Rooms:WaitForChild("Room"..mathRandom):Clone()
		roomNew.Parent = workspace
		roomNew.PrimaryPart.CFrame = startpos
		wait(0.1)
		local startpos = roomNew.Doors.Exit.CFrame
		wait(0.1)
		db = false
	end
end

Change this to:

		task.wait(0.1)
		startpos = roomNew.Doors.Exit.CFrame
		task.wait(0.1)
		db = false

As startpos is a pre-existing variable, you dont have to put local infront of it.