Gaabory
(Gabory)
March 16, 2024, 10:06am
#1
ui.MouseEnter:Connect(function()
TweenService:Create(ui,
TweenInfo.new(hoverduration,
Enum.EasingStyle.Quad,
Enum.EasingDirection.InOut),
{Position = UDim2.new(0.291, 0, 0.066, 0)}):Play()
hoversound:Play()
end)
ui.MouseLeave:Connect(function()
TweenService:Create(ui,
TweenInfo.new(0.05,
Enum.EasingStyle.Quad,
Enum.EasingDirection.InOut),
{Position = uioriginal}):Play()
end)
Basically this batch of code plays multiple times when the tween plays. I tried adding a debounce and other things but nothing seems to work.
12345koip
(12345koip)
March 16, 2024, 12:33pm
#2
How did you do your debounce? Can I see an example? It could be a problem with that.
Gaabory
(Gabory)
March 16, 2024, 12:42pm
#3
ui.MouseEnter:Connect(function()
if debounce == false then
debounce = true; task.delay(0.1, function()
debounce = false
end);
TweenService:Create(ui,
TweenInfo.new(hoverduration,
Enum.EasingStyle.Quad,
Enum.EasingDirection.InOut),
{Position = UDim2.new(0.291, 0, 0.066, 0)}):Play()
hoversound:Play()
end
end)
ui.MouseLeave:Connect(function()
if debounce == false then
debounce = true; task.delay(0.1, function()
debounce = false
end);
TweenService:Create(ui,
TweenInfo.new(0.05,
Enum.EasingStyle.Quad,
Enum.EasingDirection.InOut),
{Position = uioriginal}):Play()
debounce = true
end
end)
happya_x
(Happya)
March 16, 2024, 3:52pm
#4
I think the problem is that the tween moves the UI which triggers the other event, and it repeats in an infinite loop
Wait for the tween to be completed and then set the debounce to false
Gaabory
(Gabory)
March 17, 2024, 12:12pm
#5
ui.MouseEnter:Connect(function()
if debounce == false then
TweenService:Create(ui,
TweenInfo.new(hoverduration,
Enum.EasingStyle.Quad,
Enum.EasingDirection.InOut),
{Position = UDim2.new(0.291, 0, 0.066, 0)}):Play()
hoversound:Play()
debounce = true; task.delay(0.1, function()
debounce = false
end)
end
end)
So like this?
happya_x
(Happya)
March 17, 2024, 5:34pm
#7
assign a variable to TweenService:Create()
and then wait for its .Completed event
local tween = TweenService:Create()-- example
tween:Play()
tween.Completed:Wait() -- waits for it to end
Gaabory
(Gabory)
March 17, 2024, 9:48pm
#8
ui.MouseEnter:Connect(function()
local tweenenter = TweenService:Create(ui, TweenInfo.new(hoverduration,Enum.EasingStyle.Quad, Enum.EasingDirection.InOut), {Position = UDim2.new(0.291, 0, 0.066, 0)}):Play()
tweenenter:Play()
hoversound:Play()
tweenenter.Completed:Wait()
end)
ui.MouseLeave:Connect(function()
local tweenleave = TweenService:Create(ui, TweenInfo.new(0.05, Enum.EasingStyle.Quad, Enum.EasingDirection.InOut), {Position = uioriginal}):Play()
tweenleave:Play()
tweenleave.Completed:Wait()
end)
Like this? Because it still doesnt work
Gaabory
(Gabory)
March 17, 2024, 9:51pm
#9
It’s giving me this error too.
ne3ulimity
(ne3ulimity)
March 18, 2024, 12:02am
#10
Try this:
local debounce = false
ui.MouseEnter:Connect(function()
if not debounce then
debounce = true
local tween = TweenService:Create(ui, TweenInfo.new(hoverduration, Enum.EasingStyle.Quad, Enum.EasingDirection.InOut), {Position = UDim2.new(0.291, 0, 0.066, 0)}):Play()
hoversound:Play()
task.wait(hoverduration)
debounce = false
end
end)
ui.MouseLeave:Connect(function()
if not debounce then
debounce = true
local tween = TweenService:Create(ui, TweenInfo.new(0.05, Enum.EasingStyle.Quad, Enum.EasingDirection.InOut), {Position = uioriginal}):Play()
task.wait(hoverduration)
debounce = false
end
end)
Gaabory
(Gabory)
March 18, 2024, 7:47am
#11
I think I’m just going to give up on this then because it doesnt seem that anyone can find a solution. Thanks to everyone for trying though!
ne3ulimity
(ne3ulimity)
March 18, 2024, 1:36pm
#12
Can you send a video of the issue and maybe a place file? I’ve set up a simple screen gui and your original code works perfectly fine. There must be something else wrong.
Gaabory
(Gabory)
March 19, 2024, 7:46am
#13
I just noticed as well from this video that it seems to be that if I scroll past the UI too fast the leave animation doesn’t play either.
Gaabory
(Gabory)
March 19, 2024, 7:48am
#14