I’m working on a main menu, and when you hover over the buttons I have a tween that plays.
If you leave really fast, the tween won’t play
Example.wmv (1021.2 KB)
I know the solution probably has something to do with debounces, but I have no clue where to put them without making it worse.
Here’s my code, it’s in a LocalScript:
PlayButton = workspace.MainMenu.PlayButton
PlayTween = 1
PlayHover = false
PlayTween1 = game:GetService('TweenService'):Create(PlayButton, TweenInfo.new(1, Enum.EasingStyle.Elastic), {Orientation = Vector3.new(0,0,20)})
PlayTween2 = game:GetService('TweenService'):Create(PlayButton, TweenInfo.new(1, Enum.EasingStyle.Elastic), {Orientation = Vector3.new(0,0,-20)})
ResetPlayTween = game:GetService('TweenService'):Create(PlayButton, TweenInfo.new(1, Enum.EasingStyle.Elastic), {Orientation = Vector3.new(0,0,0)})
PlayButton.ClickDetector.MouseHoverEnter:Connect(function()
if PlayHover == true then return end
PlayHover = true
PlayButton.Light.Enabled = true
PlayButton.Gui.Label.TextColor3 = Color3.new(0.392157, 1, 0.392157)
if PlayTween == 1 then
PlayTween = 2
PlayTween1:Play()
PlayTween1.Completed:Wait()
return end
if PlayTween == 2 then
PlayTween = 1
PlayTween2:Play()
PlayTween2.Completed:Wait()
return end
end)
PlayButton.ClickDetector.MouseHoverLeave:Connect(function()
PlayHover = false
PlayButton.Light.Enabled = false
PlayButton.Gui.Label.TextColor3 = Color3.new(0.686275, 0.686275, 0.686275)
ResetPlayTween:Play()
ResetPlayTween.Completed:Wait()
end)