GUI to Mouse Scale Position

Hey, I need to set the position of a GUI to the Mouse position in Scale so if the player resize his Screen, The position will still be correct.

My issue is that the GUI is inside a frame that doesn’t cover the entire Screen.
That frame Scale is : {0.4, 0},{0.83, 0}

I can find the Mouse Scale position like that :
mouse.X / workspace.CurrentCamera.ViewportSize.X
mouse.Y / workspace.CurrentCamera.ViewportSize.Y

But I dont know how to adjust the Scale position of the GUI object base on the Frame Scale and Mouse Scale Position.

Edit : I found that in X I can solve the Position with
local x = (mouse.X - InventoryWindow.AbsolutePosition.X) / (workspace.CurrentCamera.ViewportSize.X - InventoryWindow.AbsolutePosition.X)
But in Y the same thing doesnt seems to work

Thanks for your help !

Can’t you just divide the X scale by 0.4 and divide the Y scale by 0.83? Dividing by a decimal will increase the size, which will account for how it is in a smaller frame.

if you mean someting like that
(mouse.Y / workspace.CurrentCamera.ViewportSize.Y) / Frame.Size.Y.Scale
It doesnt work

When you had your original code, was it only 0.4 as big as it should be on the Y axis?

Well If I Only take the Mouse Position divided by the Screen Size and set it to the GUI object, it move like if the Frame was the entire Screen.

You mean it’s too big? You want the frame to be smaller than the screen’s size?

I want the GUI OBject to Follow the Mouse position with his Scale Position.
That GUI Object is inside a Frame that is setup in Scale {0.4, 0},{0.83, 0}

If I feed the GUI Object the current Mouse Scale position, The GUI Object only move inside the Frame … I need to calculate the Frame screen difference in Scale.

-- Assuming you already have the Mouse and the Frame defined
local ParentFrame = Frame.Parent
local XScale = (- ParentFrame.AbsolutePosition.X + Mouse.X) / ParentFrame.AbsoluteSize.X
local YScale = (- ParentFrame.AbsolutePosition.Y + Mouse.Y) / ParentFrame.AbsoluteSize.Y
Frame.Position =, 0, YScale, 0)

Thanks a lot !
It was exactly that