Scene changed but something didnt

Godot Version

v4.2.stable

Question

` Hi, I have been devoloping a 3d game and its almost ready but ı decided to make my character answer a question in the middle of the game. But I had previously written code to direct the camera with mouse movements. I opened and designed a user interface scene, but the only problem now is that I cannot use the mouse to press the button when I switch to that scene. How can I disable this code in case of a scene change??

that was on my characterbody 3ds script
image

Simply change the mouse mode to MOUSE_MODE_VISIBLE when you spawn the UI scene and change it back to MOUSE_MODE_CAPTURED when you change the scene to your regular one.
Example below, of course it’s simplified, because I don’t know the specifics of your project, but hopefully can nudge you into the right direction.

# UI Scene spawner
func spawn_ui_scene() -> void:
    Input.set_mouse_mode(Input.MOUSE_MODE_VISIBLE)
    # spawn UI scene

func remove_ui_scene() -> void:
    Input.set_mouse_mode(Input.MOUSE_MODE_CAPTURED)
    # remove UI scene