Moving gamewindow using GDScript

Godot Version

4.2.1 mono stable

Question

I’m trying to shrink the game window and then move it to a random position on the monitor. My program crashes when trying to pick a random spot on the monitor with an ‘Invalid get index ‘x’ (on base: ‘callable’).’ my code for reference -

extends CharacterBody2D
signal hit

@export var speed = 400
@export var normSpdMulti = 2.5
@export var minimumWinSize = Vector2i(750,750)
@export var incrementalChange = Vector2i(2,2)
var isDoneX = false
var isDoneY = false
var isDone = false
var anyKeyPressed = false
var isProgReady = false
var isRandMoveDone = false
var monitorSize = DisplayServer.window_get_size


var slowMulti

func _ready():
	print_debug("started")
	await get_tree().create_timer(2).timeout
	isProgReady = true


var t = 0.0

func _physics_process(delta):
	while !isDone:
		windowShrink()
	if Input.is_anything_pressed() and !isRandMoveDone:
		var i = 0
		while i < 5:
			windowRandMove()
			await get_tree().create_timer(0.5).timeout
			i += 1
		isRandMoveDone = true


func windowShrink():
	if get_window().size.x > minimumWinSize.x:
		get_window().size.x -= incrementalChange.x
	else:
		isDoneX = true
	if get_window().size.y > minimumWinSize.y:
		get_window().size.y -= incrementalChange.y
	else: isDoneY = true
	if isDoneX and isDoneY:
		isDone = true
		
func windowRandMove():
	var randomX = RandomNumberGenerator.new()
	var randomY = RandomNumberGenerator.new()
	randomX.randomize()
	randomY.randomize()
	get_window().position = Vector2i(randomX.randi_range(0,monitorSize.x),randomY.randi_range(0,monitorSize.y))




I know that my code could be optimised a bit as well, but I can do that later.
Please help

You missed the parenthesis var monitorSize = DisplayServer.window_get_size()

Either way you are probably looking for DisplayServer.screen_get_size()

I’m kicking myself, thanks. cant believe i actually missed that