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
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.
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 = UDim2.new(XScale, 0, YScale, 0)