TextLabel is not in the correct position when hovering over part

  1. What do you want to achieve? Keep it simple and clear!
    I am trying to make a BTools/F3X Game with advanced features, one of them is hovering over a user’s part and showing who made it.

  2. What is the issue? Include screenshots / videos if possible!
    The issue is that the text does not stay near the mouse at all, i tried every solution and it stays above.
    image

  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    I’ve tried to change the TextXAlignment and TextYAlignment to Bottom and Left yet it still does not work and haven’t found any solutions on the Developer Hub.

After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!

local Player = game:GetService("Players").LocalPlayer
local Mouse = Player:GetMouse()
local RunService = game:GetService("RunService")

RunService.Heartbeat:Connect(function()
	local MouseX = Mouse.X
	local MouseY = Mouse.Y
	script.Parent.Position = UDim2.new(0, MouseX, 0, MouseY)
end)

Try absolute size and see if that helps.

But I added screengui and text label for absolute size. So, change the paths to whatever you’d like.

local Player = game:GetService("Players").LocalPlayer
local Mouse = Player:GetMouse()
local RunService = game:GetService("RunService")
local ScreenGui = Player.PlayerGui.ScreenGui
local TextLabel = ScreenGui.TextLabel

RunService.Heartbeat:Connect(function()
	local MouseX = Mouse.X
	local MouseY = Mouse.Y
	TextLabel.Position = UDim2.new(0, MouseX, 0, MouseY + TextLabel.AbsoluteSize.Y)
end)

The only thing it does now is stay on top.

1 Like

Change gui path to the gui.

local Player = game:GetService("Players").LocalPlayer
local Mouse = Player:GetMouse()
local RunService = game:GetService("RunService")
local Gui = script.Parent

RunService.Heartbeat:Connect(function()
	local MouseX = Mouse.X
	local MouseY = Mouse.Y
	Gui.Position = UDim2.new(0, MouseX, 0, MouseY + Gui.AbsoluteSize.Y/2)
end)

I am new to scripting, how do i change the position of the text tho?