MouseLeave Isn't working as intended

I have tried to add animations to my ui, but the mouseLeave event isn’t working properly as it should. Does anyone have a fix for this?

1 Like

can you share the script? I need to see what is wrong exactly

There is my code that uses the roact framework:

It directly provides the roblox events so it’s not the problem of roact tho.

[Roact.Event.MouseButton1Down] = function(element)
					local SoundController = Knit.GetController("SoundController")

					local ElementSize = UDim2.new(1,0,1,0)

					element.Size = UDim2.new(ElementSize.X.Scale * 0.8,0,ElementSize.Y.Scale * 0.8,0)
				
					SoundController.CreateSFX({
						SoundId = "rbxassetid://5852470908"
					})

				end,

				[Roact.Event.MouseButton1Up] = function(element)
					local ElementSize = UDim2.new(1,0,1,0)

					element.Size = ElementSize
					
					if self.props.SelectEvent then
						self.props.SelectEvent:Fire(self.props.PetIndex)
					end

				end,

				[Roact.Event.MouseEnter] = function(element)
					local ElementSize = UDim2.new(1,0,1,0)

					element.Size = UDim2.new(ElementSize.X.Scale * 0.9,0,ElementSize.Y.Scale * 0.9,0)

					self.props.Inventory:setState({
						PetToolTip = {
							Element = Roact.createElement(PetToolTipComponent, {
								PetInfo = self.props.PetInfo,	
							}),
							PetIndex = self.props.PetIndex
						}
					})
				end,
				
				[Roact.Event.MouseLeave] = function(element)
					local ElementSize = UDim2.new(1,0,1,0)

					element.Size = ElementSize

					self.props.Inventory:setState({
						PetToolTip = Roact.None
					})
				end,