What is the issue? Include screenshots / videos if possible!
I tried to achieve that with the script below; the only problem is that when i move out my mouse position out of the TextButtons area, the TextLabel is still here.
What solutions have you tried so far? Did you look for solutions on the Developer Hub?
I did tried to look up the DevForum, i only found about the GetGuiObjectsAtPosition, which im not used to it yet
this is the UI; the white square is the frame that’ll follow the mouse, the textlabel’s parent is the square.
local player = game.Players.LocalPlayer
local mouse = player:GetMouse()
local runService = game:GetService("RunService")
local textLabel = script.Parent.handle.textLabel
runService.RenderStepped:Connect(function()
textLabel.Parent.Position = UDim2.new(0,mouse.X,0,mouse.Y)
local guisAtPosition = player.PlayerGui:GetGuiObjectsAtPosition(mouse.X, mouse.Y)
for _, gui in pairs(guisAtPosition) do
if gui:FindFirstChild("item") then
textLabel.Text = gui:FindFirstChild("item").Value
textLabel.Visible = true
elseif gui:FindFirstChild("face") then
textLabel.Text = gui:FindFirstChild("face").Value
textLabel.Visible = true
end
end
end
I also tried to add this after the last elseif statement, but now, the textLabel doesnt display at all
Simple, just add a debounce.
Enable it when the mouse cursor is hovering the button if its hovering then set that debounce value to true.
Example:
local player = game.Players.LocalPlayer
local mouse = player:GetMouse()
local runService = game:GetService("RunService")
local textLabel = script.Parent.handle.textLabel
local isHovered = false
some_button.MouseEnter:Connect(function()
isHovered = true
end)
some_button.MouseLeave:Connect(function()
isHovered = false
end)
runService.RenderStepped:Connect(function()
textLabel.Parent.Position = UDim2.new(0,mouse.X,0,mouse.Y)
local guisAtPosition = player.PlayerGui:GetGuiObjectsAtPosition(mouse.X, mouse.Y)
for _, gui in pairs(guisAtPosition) do
if gui:FindFirstChild("item") then
textLabel.Text = gui:FindFirstChild("item").Value
textLabel.Visible = isHovered
elseif gui:FindFirstChild("face") then
textLabel.Text = gui:FindFirstChild("face").Value
textLabel.Visible = isHovered
end
end
end
NOTE: THIS IS JUST AN EXAMPLE
So you have to replace some_button with a actual button.
Yes it worked, no issues in output , thanks a lot! never tought about using only MouseEnter and MouseLeave to be honest, i always try to complicate things lol