This would end up with a square-style clamp, and not a very far one of at most 2 pixels either direction (unless you change the export variables elsewhere). And given it’s using global position the restricted movement would be to the global origin of 0, 0. It seems like an odd script, if this isn’t what you want could you explain big-picture what you are trying to do?
Cool! You might want a rounder clamp, this can be found by first finding the direction from this object to the mouse, then multiply the direction by the distance you want
var direction := global_position.direction_to(get_global_mouse_position())
position = direction * max
By assigning position here it should also work anywhere.