I have a problem with displaying text when hovering over a button in my game. I used the following script:
local button = script.Parent
local textObjectPath = script.Parent.Help
local player = game.Players.LocalPlayer
local playerMouse = player:GetMouse()
local textLabel = game:WaitForChild(textObjectPath)
textLabel.Visible = false
button.MouseEnter:Connect(function()
textLabel.Visible = true
end)
button.MouseLeave:Connect(function()
textLabel.Visible = false
end)
game:GetService("RunService").RenderStepped:Connect(function()
if textLabel.Visible then
local pos = playerMouse.Hit.Position
local guiPos = game.Workspace.CurrentCamera:WorldToViewportPoint(pos)
textLabel.Position = UDim2.new(0, guiPos.X, 0, guiPos.Y - 30)
end
end)
I need to make sure that when I hover the cursor over the button, the text appears that moves behind the cursor, but I can’t do it