Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How do i fix MouseEnter And MouseLeave Not working well?

Asked by 4 years ago
Edited 4 years ago

Sorry for my bad English in advance I've Tried to fix this issue by my self but I've come to a dead end so i'm asking for help i have a button gui in my game and I've made a local script and put the following code in it:

local Button = script.Parent.TextButton

Button.MouseEnter:Connect(function(MouseEntered)
    Button:TweenPosition(UDim2.new(0.02,0,0.5,0))
end)

Button.MouseLeave:Connect(function(MouseLeft)
    Button:TweenPosition(UDim2.new(0,0,0.5,0))
end)

im trying to make it have a selected effect when i hover over it but with the code I've shown it sometimes works when i move my mouse slowly but when i move it quickly it does not work ( https://gyazo.com/f7a603fe2a704cca9f638dbb91a83455 ) Thanks in advance for all the help :)

1 answer

Log in to vote
0
Answered by
Elyzzia 1294 Moderation Voter
4 years ago
Edited 4 years ago

TweenPosition won't work if another tween is in progress

to fix that you can use the override parameter, which is the fifth argument of the TweenPosition function

https://developer.roblox.com/en-us/api-reference/function/GuiObject/TweenPosition btw

Ad

Answer this question