TextLabel positioning is weird compared to Mouse's positioning

I’m trying to make it so if the player hovers over a TextLabel then it shows a little information thingy about that. Here is the part of the script I’m having a problem with, although I’m pretty sure it’s not in here.

for _, frame in ipairs(frames) do
	frame.MouseEnter:Connect(function()
		infobox.Visible = true
		infobox.Text = frame.Text
		rs.RenderStepped:Connect(function()
			for _, poop in ipairs(frames) do
				local m = uis:GetMouseLocation()
				infobox.Position = UDim2.fromOffset(m.X,m.Y)
			end
		end)
	end)

	frame.MouseLeave:Connect(function()
		infobox.Visible = false
	end)
end

Here are the main properties of the TextLabel.


This is what happens. (My mouse is highlighted by thankfully a red arrow!)

I want it to be above the mouse by a bit but I’ve been working on this for the past 30 minutes when it shouldn’t take this long for something this easy. Maybe I missed something idk. Help please !!!

try removing the core gui inset

Use the mouse instead of UserInputService

local m = player:GetMouse()
infobox.Position = UDim2.fromOffset(m.X,m.Y)

In case you’re still having problem with this heres what I think you need to do:
set the AnchorPoint of the frame / textlabel you want to follow your cursor to [0,1]
this puts the anchor at the bottom left corner of the label where your mouse is gonna be
in my case I named its named “FollowMouse”

this by itself should solve your problem
incase you want to change its position relative to the mouse just add to the offset m.X + offset or m.Y + offset. Hope this helps

Still no matter the AnchorPoint it still happens.
Also other 2 responses didn’t work.

could you please screenshot your whole screen so we know exactly everything thats on it?

also please give more information about the properties of the infobox, because it should not look like that unless an offset of somekind is already added to the infobox making it position so weirdly.

Ok, I think I found the issue. If i set the infobox to a different parent, like my main frame of things if that makes sense. Only reason I think it could be doing this is because I have my frames set up like this:

ScreenGui > Screen (Frame, AnchorPoint = 0.5) > Options (Frame, AnchorPoint = 1) > MainFrame (Frame, AnchorPoint = 1) > where the infobox was originally.

But uh Yeah I guess that fixes it

1 Like

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