How do I get the mouse’s position relative to a UI object?? like relative from the top left corner of the UI where the mouse is. I need this for my plugin so that when a user clicks on a button a frame appears at the position they clicked at in a UI just outside the button.
(more options is the thing I want to move)
I tried this script I found, but it didn’t work as well as I thought it would
local screenSize = camera.ViewportSize
local screenCenter = (screenSize * 0.5)
local mouse = --[[game:GetService("Players").LocalPlayer:GetMouse() --this is a plugin so I changed this]] plugin:GetMouse()
local function getRelativePos()
return (Vector2.new(mouse.X, mouse.Y) - screenCenter)
end
I’m going to guess it does work for use for getting the mouse in game, but doesn’t work for a plugin for some reason. if there’s an easy way to do this please let me know!