By default, Guis are positioned at their top-left corner. You can try changing its AnchorPoint to 0.5, 0.5, so that it’s positioned at the middle, or adjust its position like so:
local a = HoverBox.AbsoluteSize
HoverBox.Position = UDim2.new(0, plugin:GetMouse().X + a.X/2, 0, plugin:GetMouse().Y + a.Y/2)
I have a ui like this that works, the mouse is in the center of the frame 100 percent of the time
RS = game:GetService("RunService")
local Mouse = game.Players.LocalPlayer:GetMouse()
RS.RenderStepped:Connect(function()
Frame.Position = UDim2.new(here you put the scale factor you used divided by 2, Mouse.X, here you put the scale factor you used divided by 2, Mouse.Y)
end)
This worked for me. Perhaps you are setting it up wrong?
Here is the code I'm using.
-- [[ Service Declarations ]] --
local runService = game:GetService("RunService")
local coreGUI = game:GetService("CoreGui")
-- [[ Variable Declarations ]] --
--// Camera
local camera = workspace.CurrentCamera
--// UI
local container = Instance.new("ScreenGui")
local toolTipLabel = Instance.new("TextLabel")
-- [[ Function Declarations ]] --
local function updateToolTip()
local mousePosition = plugin:GetMouse()
local x, y = mousePosition.X, mousePosition.Y
toolTipLabel.Position = UDim2.new(0, x, 0, y)
end
-- [[ Init ]] --
do
--// Setup UI Properties
toolTipLabel.Size = UDim2.new(0.12, 0, 0.045, 0)
toolTipLabel.BackgroundTransparency = 0
toolTipLabel.Text = "I am Tooltip"
toolTipLabel.Parent = container
container.Parent = coreGUI
end
do
--// Signal Connections
runService.Heartbeat:Connect(updateToolTip)
end
Perhaps you want to try placing your ToolTip in CoreGui? Also, perhaps when the mouse enters a widget the new mouse location is not recorded. (Just a hypothesis though)
I’ve used you solution, It did work, but it was only showing in the range of screen, but not the plugin widget. It must be possible since Roblox could achieve Tooltip in Toolbox which is Widget.
Late response sorry. I was watching a video to find an answer to the “But it is only showing in the range of the screen”.
Around 7:05
Widgets can only detect the mouse location and all other user input typesinside the 3D viewport that you usually interact with during playtime and such. This means you will not be able to detect where the mouse is when a user is navigating the Explorer or Output window or any other widget.
Within that video there is also this:
You unfortunately will not be able to make your own ToolTips in the fashion you are trying to due to the limitations of widgets, sorry!
Also ROBLOX might use their own internal “ToolTip” methods not exposed to the Lua front-end.