UnboundLocalError: local varible 'localArea'

Hello, I am having a problem with my teleporting system:

ERROR:

Traceback (most recent call last):
  File "cognation_devBuild.py", line 45, in <module>
    run()
  File "C:\Panda3D-1.8.1\direct\showbase\ShowBase.py", line 2924, in run
    self.taskMgr.run()
  File "C:\Panda3D-1.8.1\direct\task\Task.py", line 502, in run
    self.step()
  File "C:\Panda3D-1.8.1\direct\task\Task.py", line 460, in step
    self.mgr.poll()
  File "C:\Panda3D-1.8.1\direct\showbase\EventManager.py", line 61, in eventLoopTask
    self.doEvents()
  File "C:\Panda3D-1.8.1\direct\showbase\EventManager.py", line 55, in doEvents
    processFunc(self.eventQueue.dequeueEvent())
  File "C:\Panda3D-1.8.1\direct\showbase\EventManager.py", line 122, in processEvent
    messenger.send(eventName, paramList)
  File "C:\Panda3D-1.8.1\direct\showbase\Messenger.py", line 397, in send
    self.__dispatch(acceptorDict, event, sentArgs, foundWatch)
  File "C:\Panda3D-1.8.1\direct\showbase\Messenger.py", line 482, in __dispatch
    method (*(extraArgs + sentArgs))
  File "C:\Panda3D-1.8.1\direct\gui\DirectEntry.py", line 178, in commandFunc
    apply(self['command'], [self.get()] + self['extraArgs'])
  File "C:\Users\chris_000\Dropbox\CogNation_DEVELOPMENT\cognation\main\gui\chat\CNChat.py", line 1027, in __action__
    base.localAvatar.CogTags.sendChat(message)
  File "C:\Users\chris_000\Dropbox\CogNation_DEVELOPMENT\cognation\main\gui\chat\CNChat.py", line 945, in sendChat
    if loadedArea == 'sbhq':
UnboundLocalError: local variable 'loadedArea' referenced before assignment
Press any key to continue . . .

Also here is my code:

	if (message) == '~TP DG':
		if loadedArea == 'sbhq':
			RunScreen()
			SBHQ.remove()
			SBHQ = loader.unloadModel('phase_9/models/cogHQ/SellbotHQExterior.bam')
			vtwocog.hide()
			vtwocog2.hide()
			loadedArea = 'daisygardens'
			daisygardens = loader.loadModel('phase_15/hood/daisys_garden.bam')
			daisygardens.reparentTo(render)
			localAvatar.setPosHpr(0.559869, 15.3223, 0.025,0, 0, 0)
			loadingtext['text'] = "Loading Daisy's Garden. . ."

LoadedArea is defined in a diffrent file, and is imported -Thanks

It’s difficult to speak with great confidence without seeing more context above the line in question; what the error is essentially saying is that you haven’t created the local variable “localArea” before the line in which you’re attempting to use it.

Should “localArea” belong to some object or other? (In other words, is it an instance variable–or perhaps a class variable–rather than a local variable?) If so, then you’re presumably missing the reference to the object or class in question.