You have two tweens one for when the mouse enters an area and one when it leaves … So where would you want to debounce this. From the video it looks like you’re looking to make sure the animation works as intended. So …
local ogSize = script.Parent.Size
local duration = 0.2
local button = script.Parent
local text = button.Text
local TweenService = game:GetService("TweenService")
local tweenInfo = TweenInfo.new(duration, Enum.EasingStyle.Quad, Enum.EasingDirection.Out)
local tween1 = TweenService:Create(button, tweenInfo,{TextSize = 60})
local tween2 = TweenService:Create(button, tweenInfo,{TextSize = 40})
local db = true
script.Parent.MouseEnter:Connect(function()
if db then db = false
button:TweenSize(ogSize + UDim2.new(0.1,0.1,0.1,0.1), Enum.EasingDirection.Out, Enum.EasingStyle.Quad, duration)
tween1:Play()
end
end)
script.Parent.MouseLeave:Connect(function()
if db == false then db = true
script.Parent:TweenSize(ogSize, Enum.EasingDirection.Out, Enum.EasingStyle.Quad, duration)
tween2:Play()
end
end)
This runs the 1st when they enter and runs the 2nd when they leave, blocking all other outcomes.
It’s a double debounce and a toggle at the same time.
I see no reason this wouldn’t work … did you even try it.
Havent programmed lua in over a year so, bear with me…
local ogSize = script.Parent.Size
local duration = 0.2
local button = script.Parent
local text = button.Text
local TweenService = game:GetService("TweenService")
local tweenInfo = TweenInfo.new(duration, Enum.EasingStyle.Quad, Enum.EasingDirection.Out)
local tween1 = TweenService:Create(button, tweenInfo, {TextSize = 60})
local tween2 = TweenService:Create(button, tweenInfo, {TextSize = 40})
local debounce = false
script.Parent.MouseEnter:Connect(function()
if not debounce then
debounce = true
button:TweenSize(ogSize + UDim2.new(0.1, 0.1, 0.1, 0.1), Enum.EasingDirection.Out, Enum.EasingStyle.Quad, duration)
tween1:Play()
wait(duration) -- Wait for the animation to finish before allowing another mouse event
debounce = false
end
end)
script.Parent.MouseLeave:Connect(function()
if not debounce then
debounce = true
script.Parent:TweenSize(ogSize, Enum.EasingDirection.Out, Enum.EasingStyle.Quad, duration)
tween2:Play()
wait(duration) -- Wait for the animation to finish before allowing another mouse event
debounce = false
end
end)
Ive noticed that in all the ways ive tried here, (everyone’s suggestions), that it still continues to either get stuck as big, but no longer the text remains enlarged. Occasionally, when the mouse leaves the button, the GUI remains enlarged.
maybe you could do something where you wait for the mouse to leave in the same function as the mouse enter (sorry for bad explanation will try to show example)
script.Parent.MouseEnter:Connect(function()
if not debounce then
debounce = true
button:TweenSize(ogSize + UDim2.new(0.1, 0.1, 0.1, 0.1), Enum.EasingDirection.Out, Enum.EasingStyle.Quad, duration)
tween1:Play()
wait(duration) -- Wait for the animation to finish before allowing another mouse event
debounce = false
script.Parent.MouseLeave:Connect(function()
if not debounce then
debounce = true
script.Parent:TweenSize(ogSize, Enum.EasingDirection.Out, Enum.EasingStyle.Quad, duration)
tween2:Play()
wait(duration) -- Wait for the animation to finish before allowing another mouse event
debounce = false
end
end)
end
end)
You can’t change the button without changing text size without making some sort of algorithm for calculating the exact ratio the text si- I’m not even going to bother explaining this, it’s way too much work for what you want.
Why don’t you just make a textLabel over the button, where the text is the exact size? With transparent backgroundand clickthrough enabled. Then if you want the text to change (for example to change color) when you hover over the button you can just do something like
I would do that honestly, and I have before, but I have seen it in numerous other games and so I wish to achieve that lmao.
Its pretty close, I just think that MouseEntered/MouseLeave is running too slowly and so I will have to find another way.
I found help on a forum on Discord and I found that removing my UI size constraint allowed me to fix the problem.
local ogSize = script.Parent.Size
local button = script.Parent
local duration = 0.2
local TweenService = game:GetService("TweenService")
local tweenInfo = TweenInfo.new(duration, Enum.EasingStyle.Quad, Enum.EasingDirection.Out)
local tween1 = TweenService:Create(button, tweenInfo, {Size = ogSize + UDim2.new(0.1,0.1,0.1,0.1), TextSize = 60})
local tween2 = TweenService:Create(button, tweenInfo, {Size = ogSize, TextSize = 40})
script.Parent.MouseEnter:Connect(function()
if button.MouseEnter then
print("mouse entered")
end
tween1:Play()
end)
script.Parent.MouseLeave:Connect(function()
if button.MouseLeave then
print("mouse left")
end
tween2:Play()
end)
Code for anyone with issues, thank you to everyone who helped me ( sorry I cant give all yall the solution check )