I got this custom mouse on enter and it works fine with one textbutton but when i add another textbutton so there's two of them i can only hover on one of them and the mouseenter frame opens why is this?
local module = {}
local RunService = game:GetService("RunService")
local Player = game.Players.LocalPlayer
local Mouse = Player:GetMouse()
local PlayerGui = Player:WaitForChild("PlayerGui")
local ScreenGui = PlayerGui:WaitForChild("ScreenGui")
local Buttons = ScreenGui:FindFirstChild("Buttons")
local MouseHover = ScreenGui:FindFirstChild("MouseHover")
local function IsInUIElement(MousePos, ElementPos, ElementSize)
return (MousePos.X >= ElementPos.X and MousePos.X < ElementPos.X + ElementSize.X) and (MousePos.Y >= ElementPos.Y) and (MousePos.Y < ElementPos.Y + ElementSize.Y)
end
function module.Init()
local Clicked = false
RunService.RenderStepped:Connect(function()
for i,v in pairs(Buttons:GetChildren()) do
if v:IsA("TextButton") then
v.MouseButton1Click:Connect(function()
if not Clicked then
Clicked = true
if v.Name == "Premium Shop" then
elseif v.Name == "Quests" then
ScreenGui:WaitForChild("Quests").Visible = not ScreenGui:WaitForChild("Quests").Visible
end
wait(0.01)
Clicked = false
end
end)
print(v)
if IsInUIElement(Vector2.new(Mouse.X, Mouse.Y), v.AbsolutePosition, v.AbsoluteSize) then
MouseHover.Visible = true
MouseHover.Position = UDim2.new(0, Mouse.X, 0, Mouse.Y)
MouseHover.ButtonName.Text = v.Name
else
MouseHover.Visible = false
end
end
end
end)
end
return module

2 comments
uhh you do know there are MouseEnter and MouseLeave functions don't you?!?!?
You know thoser are buggy right?