Unable to make the game FullScreen and back to Windowed during runtime

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By AnindyaRoy

I wrote this code to make my game fullscreen and back to windowed during runtime in the script of my main menu. But it doesn’t seem to work even when I press the key in Main Menu

The Code
In case you are unable to see the image here is the code:

func _process(delta: float) → void:
if Input.is_action_just_pressed(“FullScreen”):
if ProjectSettings.get_setting(“display/window/size/fullscreen”):
ProjectSettings.set_setting(“display/window/size/fullscreen”, false)
ProjectSettings.set_setting(“display/window/size/fullscreen”, true)

:bust_in_silhouette: Reply From: jgodfrey

See the answer here: