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

Help with MouseEnter and MouseLeave?

I have this script, and it works fine, but when I hover over it too quickly, it stays on mouseEnter until I put my mouse on it again to fix it. Any help?

framebutton.MouseEnter:connect(function()
active = true
	local keyConnection = framebutton.MouseLeave:connect(function()
		open:TweenPosition(UDim2.new(-0.07,0,0.51,0),EasingDirection,EasingStyle,float)
		active = false
	end)
	open:TweenPosition(UDim2.new(-0.05,0,0.51,0),EasingDirection,EasingStyle,float)
	repeat wait () until active == false
	keyConnection:disconnect()
end)

1 answer

✓ Accepted answer

It looks like the MouseLeave function is under the same function for MouseEnter

Try this for the script

framebutton.MouseEnter:connect(function()
active = true
        open:TweenPosition(UDim2.new(-0.07,0,0.51,0),EasingDirection,EasingStyle,float)
    end)

 framebutton.MouseLeave:connect(function()
        active = false
    open:TweenPosition(UDim2.new(-0.05,0,0.51,0),EasingDirection,EasingStyle,float)
end)

that should fix the issue hope I helped! :D

6 comments

0

If I helped you and it works for you now please accept my Answer as a Answer it'll Increase my rep and your rep! :D

0

Attempted to index global value 'keyConnection'

0

try it now

0

I edited the script

0

thanks it worked!

0

No problem! :D

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