When resizing gui it changes depending on the resolution of the screen

as you can see in the video when the screen was bigger when i resize the gui it goes lower then my mouse heres the code and when its smaller it jumps over it

wait(1)
local App = script.Parent
local Window = App.Window
local Over = App.Overlay
local vp = game.Workspace.Camera.ViewportSize

print(vp)

Window.Drag.MouseButton1Down:connect(function()
	Over.Visible = true
	local Move = Over.MouseMoved:connect(function(X,Y)
		local x = X-Window.AbsolutePosition.X-(Window.Drag.Size.X.Offset/2)+10
		local y = math.floor(((Y-(Window.Drag.Size.Y.Offset/2))/20)-14.2)*20
		if x < 400 then x = 400 end
		if y < 100 then y = 100 end
		Window.Size = UDim2.new(0,x,0,y)
	end)
	local Up
	local Leave
	Up = Over.MouseButton1Up:connect(function()
		Move:disconnect()
		Up:disconnect()
		Leave:disconnect()
		Over.Visible = false
	end)
	Leave = Over.MouseLeave:connect(function()
		Move:disconnect()
		Up:disconnect()
		Leave:disconnect()
		Over.Visible = false
	end)
end)

this part of the code

local x = X-Window.AbsolutePosition.X-(Window.Drag.Size.X.Offset/2)+10
local y = math.floor(((Y-(Window.Drag.Size.Y.Offset/2))/20)-14.2)*20

the +10 at the end of local x is the offset to fit nice with dragging the resize button
same as the -14.2 is there a way to change these depending on the resolution of the screen

the -14.2 is made for 1957, 997
so when you go higher then that resolution it drops down under the mouse

and if you go higher then that resolution it will jump over the mouse

There’s no video attached. Are you trying to make a frame that is resizable by the player?

I’m not sure but I think you could just use scale to make the gui changes depending of the player’s screen resolution.

my bad it was 3 am when i made this i added the video