How would I make a hover note for a image label?

Hello! So I’m a developer of a game that a friend of mine is making and he wants me to help with a customization screen. I’m currently trying to make a hover note that appears when you hover over a button and says what part of the customization screen it will take you to.

This is the code that I tried:

local Player = game.Players.LocalPlayer
local Mouse = Player:GetMouse()
local InfoGui = script.Parent.TextLabel

function hover()
    if Mouse.Target == script.Parent then
	    InfoGui.Position = UDim2.new(0, Mouse.X, 0, Mouse.Y)
    end
end

Mouse.Move:Connect(hover())

Sorry if this is really easy, I don’t use GetMouse() very often.
Thanks!

1 Like

This is better

local InfoGui = script.Parent.TextLabel

script.Parent.MouseMoved:Connect(function(X, Y)
	InfoGui.Position = UDim2.new(0, X, 0, Y)
end)
script.Parent.MouseEnter:Connect(function()		InfoGui.Visible = true		end)
script.Parent.MouseLeave:Connect(function()		InfoGui.Visible = false		end)

Remove the last 2 lines if always GuiObject should be visible.

Sources:
https://developer.roblox.com/en-us/api-reference/event/GuiObject/MouseMoved
https://developer.roblox.com/en-us/api-reference/event/GuiObject/MouseEnter
https://developer.roblox.com/en-us/api-reference/event/GuiObject/MouseLeave

Also, Mouse.Target is used for 3d objects.

2 Likes

It worked but not completely.

This is what happens:

robloxapp-20210713-1704261.wmv (192.9 KB)

EDIT I fixed it. Instead of doing:

InfoGui.Position = UDim2.new(0, X, 0, Y)

I did:

InfoGui.Position = UDim2.new(-4.5, X, -5, Y)
1 Like

Make the parent of InfoGui be the ScreenGui or that its parent be in UDim2.new(0,0,0,0), also, if IgnoreGuiInset is deactivated, activate it or add this line

Y -= game.GuiService:GetGuiInset().Y

below this

1 Like

Thank you so much for the help!

2 Likes

You’re welcome, happy to help ^-^

1 Like