PcoWSkbVqDnWTu_dm2ix
We use cookies on this site to enhance your user experience
Collapse Sidebar

GetRelativeMousePosition

GetRelativeMousePosition returns the position of the mouse relative to the top-left corner of the PluginGui. The returned value changes only if a mouse input began on the PluginGui, or if the mouse is presently hovering over the window.

An animation of the return value of Plugin:GetRelativeMousePosition

The animation above displays the value returned by this function (the left mouse button is pressed in the animation). Notice how the X-value is negative when the mouse is on the left of the window.

Returns

Return Type Summary

The screen position of the mouse relative to the PluginGui in pixels


Code Samples


PluginGui:GetRelativeMousePosition

local RunService = game:GetService("RunService")

local widgetInfo = DockWidgetPluginGuiInfo.new(
	Enum.InitialDockState.Float,
	true, false, -- Enabled state, override
	200, 300,    -- Size
	150, 150     -- Minimum size
)

local testWidget = plugin:CreateDockWidgetPluginGui("TestWidget", widgetInfo)

function update()
	local v2 = testWidget:GetRelativeMousePosition()
	testWidget.Title = ("(%d, %d)"):format(v2.x, v2.y)
end
RunService.Stepped:connect(update)
update()