Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

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

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

✓ Accepted answer

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

1 comment

0

Thank you so much, I had complety forgotten about the ViewportSize propertie!

This discussion is preserved as it was. New answers, comments, and votes are closed.