Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Gui doesn't tween back in if your mouse leaves it before a tween has finished? [Solved]

For some reason, if my mouse leaves the gui before it has finished tweening it does not tween back, and it stays tweened out, some help would be appreciated.

local hover = false

script.Parent.MouseEnter:connect(function()
	if not hover then	
	script.Parent:TweenPosition(UDim2.new(0, 0, 0.74, 0), "Out", "Sine", 0.2)
		hover = true	
	end
end)

script.Parent.MouseLeave:connect(function()
	hover = false	
	script.Parent:TweenPosition(UDim2.new(-0.095, 0, 0.74, 0), "Out", "Sine", 0.2)
end)

1 answer

Thanks to Pyrondon, my problem has now been solved. I had to add a boolean at the end of both the tweens.

local hover = false

script.Parent.MouseEnter:connect(function()
    if not hover then   
    script.Parent:TweenPosition(UDim2.new(0, 0, 0.74, 0), "Out", "Sine", 0.2, true)
        hover = true    
    end
end)

script.Parent.MouseLeave:connect(function()
    hover = false   
    script.Parent:TweenPosition(UDim2.new(-0.095, 0, 0.74, 0), "Out", "Sine", 0.2, true)
end)

This discussion is preserved as it was. New answers, comments, and votes are closed.