Using the code bellow, I making a GUI visible when the mouse enters a button, but when the mouse leaves the button there is a very long delay before it disappears, does anyone know what is causing this?
My Messy code:
local CurrentInGameGuns = Player.PlayerGui.Menu.Frame.Guns.ScrollingFrame.Main:GetChildren()
for i,v in pairs(CurrentInGameGuns) do
if v.Name ~= "UIGridLayout" then
v.MouseEnter:Connect(function()
UserInputService.MouseIconEnabled = false
local Base = script.Base:Clone()
local GunDatabase = require(game.ReplicatedStorage.Modules.GunSystem.GunSystemMain.GunIDS.IDLIST)
Base.Parent = Player.PlayerGui.OverlayContent
local GunID = GunDatabase[tonumber(v.GunID.Value)]
local GunInfo = require(game.ReplicatedStorage.Modules.GunSystem.GunSystemMain.GunConfiguration[GunID])
Base.Frame.Blocks.Description.desc.Text = GunInfo[1]["Desc"]
Base.Frame.Blocks.PriceCredits.Price.Text = GunInfo[1]["price"]
Base.Frame.Blocks.Title.title.Text = GunInfo[1]["Name"]
runService.RenderStepped:Connect(function() -- constantly updates based on frames
Base.Position = UDim2.new(0, Mouse.X, 0, Mouse.Y) -- changing the offset values
end)
end)
v.MouseLeave:Connect(function()
Player.PlayerGui.OverlayContent:WaitForChild("Base"):Destroy()
UserInputService.MouseIconEnabled = true
end)
end
end