How to make UI follow player's mouse?

I want to make it so whenever a player hovers a UI item, another UI item appears and follows their mouse while they are hovering over the initial item.

The appear and disappear part is easy, obviously, but how do i make the newly appeared UI follow the player’s mouse?

Follow as in interpolates to their mouse’s position? Or immediately gets positioned near the mouse?

1 Like


Something like this

The new UI appears at the bottom border of the mouse, something like that.

local mouse = game.Players.LocalPlayer:GetMouse()

local function positionAtMouse(box)
local frameSize = box.AbsoluteSize

--//positions at left corner of mouse
box.Position = UDim2.fromOffset(mouse.X - frameSize.X, mouse.Y)
end
5 Likes