How do I position a GUI at mouse position?

Why can’t I position a UI at mouse position, this seems this happen

Script:


function _G.GetMouseLocation()
	return UIS:GetMouseLocation()
end

ScreenGui.DisplayTraitsFrame.Hovering.Position = UDim2.fromOffset(_G.GetMouseLocation().X, _G.GetMouseLocation().Y)


You probably need to subtract DisplayTraitsFrame.AbsolutePosition.X and Y.

2 Likes

can you elaborate more on this please ?

Hovering is what you want to position, right? The position of DisplayTraitsFrame is automatically added onto the position of the Hovering frame. So if the Hovering frame is located at the mouse position, the true position will be the mouse position plus whatever position DisplayTraitsFrame is at. So this isn’t an issue if DisplayTraitsFrame is located at exactly 0,0. If DisplayTraitsFrame is not at exactly 0,0, then you need to subtract its position from the mouse position.

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