How can I get the scale position of the mouse?

To get the position of the local mouse = game.Players.LocalPlayer:GetMouse() -- This must be a localscript xD you have to do: print(mouse.X, mouse.Y), but this returns the position of the mouse in pixels / offset, and I want to use scale to get the position. Not offset. And if I use mouse.Position.X.Scale I get an error.

How can I get the position of the mouse on the screen in scale?


Divide it by the total screen size.


How would I get that?

30 charZ

workspace.CurrentCamera.ViewportSize should be what you’re looking for.


@FieryEvent @posatta But why when I do this, I get two values instead of one value?

Screenshot (68)

ViewportSize is a Vector2, so it should have X and Y properties much like the mouse’s position.


Excuse me for the bump, but if you’re working with Gui’s, getting it’s ScreenGui property “AbsoluteSize” is similar to getting the ViewportSize. The only difference is that it has the Roblox’s Gui Inset bar(The black transparent bar at the top that has your game settings/chat/players).

workspace.CurrentCamera.ViewportSize -- > Vector2(x, y)

-- Child of a ScreenGui
script.Parent.AbsoluteSize -- > Vector2(x, y - 36) -- 36 is the Offset size of the Inset bar.

If you’d like to disable the inset just do ScreenGui.IgnoreGuiInset = true. Or you can just subtract 36 pixels from the Y Offset.

Edit: UDim2 seems to base it’s calculation using any ScreenGui’s AbsoluteSize so long as it’s IgnoreGuiInset is set to false.