Warping into another model/room

Got another qestion when I was working on my maps, how do you go about “warping” to the nexts map? I tried something like this when I press k. I know you should destory the 1st so you can rebuild the new one, (other wise they will just overlap, thats what its doing with this code), not sure how to go about doing this tho.

Updata: After some rereading I found the code that well make hte model go away (witch I was right the 1st time) just it gives me a error with how my code is setup. errer: UnboundLocalError: local variable ‘environ’ referenced before assignment
Meaning its being called somehow befor environ can be called, not sure how to get around it.–I think anyways lol.

class World(DirectObject):
    def __init__(self):
	f = open("networking/Users/Mradr.txt","r")
	lineList = f.readlines()
	print repr(lineList[2]) 

	town = lineList[2].strip()
	#Load the first environment model town.egg 
	environ = loader.loadModel(town)

	#waterpiller = loader.loadModel("towns/water")
	#watershader = Shader.load("shaders/water.sha")


	self.keyMap = {"left":0, "right":0, "forward":0, "back":0, "warp":0}

        # Accept the control keys for movement
        self.accept("escape", sys.exit) 
        self.accept("arrow_left", self.setKey, ["left",1]) 
        self.accept("arrow_right", self.setKey, ["right",1])
        self.accept("arrow_up", self.setKey, ["forward",1])
        self.accept("arrow_down", self.setKey, ["back",1])
        self.accept("arrow_left-up", self.setKey, ["left",0]) 
        self.accept("arrow_right-up", self.setKey, ["right",0]) 
        self.accept("arrow_up-up", self.setKey, ["forward",0])
        self.accept("arrow_down-up", self.setKey, ["back",0])
	self.accept("k", self.setKey, ["warp",1])  	
	self.accept("k_up", self.setKey, ["warp",0])


	# Game state variables 
        self.prevtime = 0

	#disable camera
	if town == "towns/a":
	#if town == "towns/controlroom":

	#background color


    #Records the state of the arrow keys 
    def setKey(self, key, value): 
        self.keyMap[key] = value 

    def move(self, task):

        elapsed = task.time - self.prevtime

        camright = base.camera.getNetTransform().getMat().getRow3(1)
        if (self.keyMap["left"]!=0): 
            	base.camera.setH(base.camera.getH() + elapsed*250)
        if (self.keyMap["right"]!=0): 
           	base.camera.setH(base.camera.getH() - elapsed*250)
        if (self.keyMap["forward"]!=0):
            	base.camera.setPos(base.camera.getPos() + camright*(elapsed*500))
        if (self.keyMap["back"]!=0):
           	base.camera.setPos(base.camera.getPos() - camright*(elapsed*500))
	if (self.keyMap["warp"]!=0):
		#Load the first environment model town.egg
		environ = loader.loadModel("towns/controlroom")  

your “environ” is local to init functions so when you get to move its gone. Its still at the redner but no longer in python. Use self.environ to make it part of the World class.

Omg thank you x.x I spent the last week trying to get this dang code to work and couldnt come up with the answer at all x.x;

Panda 3d is a very to use library but you need to know some thing about python first. I recommend doing some python tutorials fist: diveintopython.org/