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

How would I make this MouseEnter//Leave function not get stuck and not Leave?

My current code:

function HoverOn()
script.Parent:TweenPosition(UDim2.new(0,5,0,0), "In", "Sine", 0.1)
end


function HoverOff()
script.Parent:TweenPosition(UDim2.new(0,0,0,0), "Out", "Sine", 0.1) 
end

script.Parent.MouseEnter:connect(HoverOn)
script.Parent.MouseLeave:connect(HoverOff)

Explanation: It works okay, but when you quickly move your mouse off of it, it doesn't trigger the MouseLeave. It's like a selection notifier, hard to explain. It just makes the GUIs look fancy.

Example: http://i.imgur.com/jZJQEhH.gif

See the ones still sticking out, and the MouseLeave event clearly wasn't fast enough to trigger? I don't want that happening. It also seems like clicking on it completely screws up the MouseLeave as well.

Any solutions?

1 answer

✓ Accepted answer

If you look at the wiki page for TweenPosition, you'll notice another argument that you didn't include when you called it in your code. This argument is override. It determines whether the the tween can be overridden by another tween. Since you didn't include it, it will default to false, i.e., you will not be able to start a new tween until the first tween is finished.

I believe this is your problem. When you move your mouse quickly, the MouseLeave event does fire, but the first tween is still happening, and it can't be overridden. This means It just finishes, then stops. I believe you can fix this just by setting the override argument to true.

script.Parent:TweenPosition(UDim2.new(0,5,0,0), "In", "Sine", 0.1, true)

1 comment

0

PERFECTO, THANK YOU!!!

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