How would I create this popup effect?

So as a UI Designer I am trying to figure out how to create this effect where a popup follows the user’s cursor:

I mainly don’t understand how to find the player’s cursor position and rapidly update it, I know how to make the popup appear on hover, just not how the position is found. Sorry if confusing.

2 Likes

You should use:

UIS = game:GetService("UserInputService")

MousePosition = UIS:GetMouseLocation()

It returns a vector2

2 Likes

For what it’s worth, this is known as a tooltip, so you might have more luck using that term when searching or asking for help.

thanks, but how would I update the position every time the mouse is moved?

1 Like

Just make a tooltip element which is always at the mouse pos. Then, set it’s text to whatever the player hovers over. Only make it visible when hovering over something.

To keep it locked to the mouse, just connect a function to UserInputService.InputChanged. Check if the input object is Enum.UserInputType,MouseMovement, and if it is you just move the tooltip to input.Position.X,input.Position.Y+GUI_inset.Y

That doesn’t solve my problem. Please read the thread before replying.

Actually, it does solve your problem.

Update the position of an element to the mouse location.

local tooltipLabel = script.Parent.TooltipLabel
local tooltipHeight = tooltipLabel.Size.Y.Offset
local horizontalOffset = 10
local verticalOffset = -tooltipHeight / 2
local userInputService = game:GetService(“UserInputService”)

local mousePos = userInputService:GetMouseLocation()
local adjustedPos = UDim2.new(0, mousePos.X + horizontalOffset, 0, mousePos.Y + verticalOffset)
tooltipLabel.Position = adjustedPos

Nevermind, I figured out I can use RunService heartbeats to do this.

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