How to get mouse pos in just a frame not whole screen


i want just the mouse position for the white rectangle but it gives for the whole screen
EX: if i click on the middle of the right black line it will not give 1,0,.5,0, but it should

local mouse = game.Players.LocalPlayer:GetMouse()
local viewSize = game.Workspace.CurrentCamera.ViewportSize
local absoluteSize = player.PlayerGui.Workspace.characters.AbsoluteSize -- this is absolute size for the white frame, i didnt use this for any of the code because i dont know how to implement it
local x = mouse.X/viewSize.X -- this coverts the mouse pos to scale instead of offset
local y = mouse.Y/viewSize.Y  -- this coverts the mouse pos to scale instead of offset

THANKS FOR ANY HELP :love_you_gesture:

guys yay i figured it out. here a script just incase anyone sees this post and need help

local mouse = game.Players.LocalPlayer:GetMouse()
local absoluteSize = player.PlayerGui.Workspace.characters.AbsoluteSize
local absolutePos = player.PlayerGui.Workspace.characters.AbsolutePosition
local x1 = mouse.X - absolutePos.X
local y1 = mouse.Y - absolutePos.Y
local x = x1/absoluteSize.X -- gives you mouse position X in scale
local y = y1/absoluteSize.Y -- gives you mouse position Y in scale
2 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.