Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How do I change my mouse X from pixels to Scale?

Asked by 5 years ago

So, I have this one script that gets the mouse X however I need it to get the X in Scale instead of pixels. How is it possible to change that up?

local Players = game:GetService("Players")
local player = Players.LocalPlayer 
local mouse = player:GetMouse()


function moyse()

local position = mouse.X


    print(position)

return position


end
mouse.Move:Connect(moyse)

1 answer

Log in to vote
0
Answered by
Rare_tendo 3000 Moderation Voter Community Moderator
5 years ago

As y'know, the Scale of a gui's position or size is represented as a decimal of the percentage of the gui's position divided by that of its parent's.

You can calculate scale by: (dimensionPos / parentDimensionPos)

The mouse will be the gui, and the screen will be the parent

In your case, this'll be:

local scale = position / workspace.CurrentCamera.ViewPortSize.X
0
Thank you so much, I had complety forgotten about the ViewportSize propertie! prooheckcp 340 — 5y
Ad

Answer this question