Next time I should post the whole script.
if source == resumeButton then
openPauseMenu()
elseif source == optionsButton then
if currentWindow then
destroyElement ( currentWindow )
end
currentWindow = createWindow ( 300, 200, 400, 650, "Options" )
elseif source == myinfoButton then
if currentWindow then
destroyElement ( currentWindow )
end
currentWindow = createWindow ( 300, 200, 400, 650, "Information" )
elseif source == graphicsButton then
if currentWindow then
destroyElement ( currentWindow )
end
currentWindow = createWindow ( 300, 200, 400, 650, "Graphics" )
end
It checks if another one was created before, it must destroy it and create a new one.