Hey, I’ve been experiencing this bug with a lot of my games and I don’t really have a solution to fix this. So here’s the problem,
The script works entirely fine. Though when hovering the buttons multiple times, the buttons start to appear larger than they should be. They should only increase by x1.5 upon being hovered but they instead end up becoming bigger when the hovering event is triggered multiple times. Here’s a block of code for the script and an image showcasing this bug:
local Players = game:GetService("Players")
local TweenService = game:GetService("TweenService")
local LocalPlayer = Players.LocalPlayer
local Mouse = LocalPlayer:GetMouse()
local Frame = script.Parent.Parent:WaitForChild("MainFrame").ButtonsFrame
local TempHolder = script:WaitForChild("SparklesHolder")
local TempSpark = script:WaitForChild("Sparkle")
local SizeMulti = 1.15 -- Cartoonish size multiplier
local RotMulti = -90 -- Cartoonish rotation effect
local HoverDebounce = {} -- Table to track debounce for each button
local SFX = script:WaitForChild("HoverSFX")
local SFX2 = script:WaitForChild("ClickSFX")
local function createRandomSparkle(Holder)
local Sparkle = TempSpark:Clone()
Sparkle.Parent = Holder
Sparkle.Position = UDim2.new(math.random(), 0, math.random(), 0)
Sparkle.Size = UDim2.new(0, math.random(10, 30), 0, math.random(10, 30))
local InTween = TweenService:Create(Sparkle, TweenInfo.new(0.5, Enum.EasingStyle.Bounce, Enum.EasingDirection.Out), { Size = UDim2.fromScale(0.3, 0.3)})
InTween:Play()
InTween.Completed:Connect(function()
local OutTween = TweenService:Create(Sparkle, TweenInfo.new(0.5, Enum.EasingStyle.Bounce, Enum.EasingDirection.In), { Size = UDim2.fromScale(0, 0)})
OutTween:Play()
OutTween.Completed:Connect(function()
Sparkle:Destroy()
end)
end)
end
local function onHover(UI)
local Descendants = Frame:GetDescendants()
for _, var in ipairs(Descendants) do
if (var:IsA("ImageButton") or var:IsA("TextButton")) and not var:GetAttribute("Nobtneffect") then
HoverDebounce[var] = false
var.MouseEnter:Connect(function()
if HoverDebounce[var] then return end
HoverDebounce[var] = true
local OgSize = var.Size
local Icon = var:FindFirstChildOfClass("ImageLabel") or var.BtnIcon
local Holder = TempHolder:Clone()
Holder.Parent = var
Holder.ClipsDescendants = true
local HoverSFX = SFX:Clone()
HoverSFX.Parent = var
HoverSFX:Play()
local TweenGoal = {
Size = UDim2.new(OgSize.X.Scale * SizeMulti, OgSize.X.Offset * SizeMulti, OgSize.Y.Scale * SizeMulti, OgSize.Y.Offset * SizeMulti),
}
local HighlightGoal = {
Color = Color3.new(1, 1, 1),
Thickness = 6,
Transparency = 0
}
local HighTween = TweenService:Create(var.BorderStroke, TweenInfo.new(0.6, Enum.EasingStyle.Quad, Enum.EasingDirection.Out), HighlightGoal)
local IconTween = TweenService:Create(Icon, TweenInfo.new(0.6, Enum.EasingStyle.Quad, Enum.EasingDirection.Out), { Rotation = RotMulti })
local FXTween = TweenService:Create(var, TweenInfo.new(0.6, Enum.EasingStyle.Elastic, Enum.EasingDirection.Out), TweenGoal)
HighTween:Play()
IconTween:Play()
FXTween:Play()
spawn(function()
while HoverDebounce[var] do
createRandomSparkle(Holder)
wait(0.45)
end
end)
var.MouseLeave:Connect(function()
HoverDebounce[var] = false
Holder:Destroy()
local TweenGoal2 = {
Size = OgSize,
}
local HighlightGoal2 = {
Color = Color3.new(0, 0, 0),
Thickness = 4,
Transparency = 0.75
}
local HighTweenBack = TweenService:Create(var.BorderStroke, TweenInfo.new(0.4, Enum.EasingStyle.Quad, Enum.EasingDirection.Out), HighlightGoal2)
local IconTweenBack = TweenService:Create(Icon, TweenInfo.new(0.4, Enum.EasingStyle.Quad, Enum.EasingDirection.In), { Rotation = 0 })
local FXTweenBack = TweenService:Create(var, TweenInfo.new(0.4, Enum.EasingStyle.Back, Enum.EasingDirection.In), TweenGoal2)
HighTweenBack:Play()
IconTweenBack:Play()
FXTweenBack:Play()
end)
HoverSFX.Ended:Connect(function()
HoverSFX:Destroy()
end)
end)
var.MouseButton1Click:Connect(function()
local ClickSFX = SFX2:Clone()
ClickSFX.Parent = var
ClickSFX:Play()
local ImgFX = script.OverlayFX:Clone()
local Clip = Instance.new("CanvasGroup", var)
Clip.Name = "OverlayClipping"
Clip.Size = UDim2.new(1, 0, 1, 0)
Clip.Position = UDim2.new(0, 0, 0, 0)
Clip.BackgroundTransparency = 1
Clip.ClipsDescendants = true
ImgFX.Parent = Clip
local x, y = (Mouse.X - ImgFX.AbsolutePosition.X), (Mouse.Y - ImgFX.AbsolutePosition.Y)
ImgFX.Position = UDim2.new(0, x, 0, y)
local size = math.max(var.AbsoluteSize.X, var.AbsoluteSize.Y) * 1.5
ImgFX:TweenSizeAndPosition(
UDim2.new(0, size, 0, size),
UDim2.new(0.5, -size / 2, 0.5, -size / 2),
Enum.EasingDirection.Out,
Enum.EasingStyle.Elastic,
0.3
)
wait(0.15)
ImgFX:Destroy()
Clip:Destroy()
ClickSFX:Destroy()
end)
end
end
end
spawn(onHover)
I’ve tried using Debounce for this but it still hasn’t been working up until now. If anyone could fix this it’d be really great.
