So this line doesn't make sense to me:
grid_size = OS.get_screen_size()
The grid size should be a fixed integer number, like 8 or 16.
var x = round(parent.position.x / grid_size.x)
var y = round(parent.position.y / grid_size.y)
If you want the x to be smooth, you shouldn't include it in the grid calculation.
var new_grid_position = Vector2(parent.position.x, y)