how can i go from one scene to an oder ?

func didBegin(_ contact: SKPhysicsContact) {
        var bodyA = contact.bodyA
        var bodyB = contact.bodyB
       
        if bodyA.categoryBitMask == 1 && bodyB.categoryBitMask == 2 || bodyA.categoryBitMask == 2 && bodyB.categoryBitMask == 1 {
            let gamescene = GameScene(fileNamed: "endscene")
            self.scene?.view?.presentScene(gamescene)
            timer.invalidate()
           
           
           
           
           
          
          
           
                }
    }

i need to save the time to an oder scene and go to that scene how do i do that