So whenever my mouse click and leave too fast on the button the size of the button keep staying at the MouseEnter size instead of the MouseLeave size. Here is the code:
local NewOptionBtn = OptionButton:Clone()
NewOptionBtn.Parent = DialogOptionsHolder
NewOptionBtn.Name = OptionName
NewOptionBtn.Text = OptionText
NewOptionBtn.Size = UDim2.new(0, 0, 0, 0)
Utils.Spring.target(DialogOptionsHolder, .5, 3, {
Size = UDim2.new(0.217, 0, 0.776, 0)
})
Utils.Spring.target(NewOptionBtn, 1, 3, {
Size = UDim2.new(1, 0, 0.19, 0)
})
task.delay(.25, function()
if not CanClicksList[NewOptionBtn] then
CanClicksList[NewOptionBtn] = true
end
end)
Interface.OnHoverEnter(NewOptionBtn, function()
if CanClicksList[NewOptionBtn] then
print('a')
Utils.Spring.target(NewOptionBtn, .35, 5, {
Size = UDim2.fromScale(OptionButton.Size.X.Scale - .015, OptionButton.Size.Y.Scale - .015)
})
end
end)
Interface.OnHoverLeave(NewOptionBtn, function()
if CanClicksList[NewOptionBtn] then
print('b')
Utils.Spring.target(NewOptionBtn, .35, 5, {
Size = OptionButton.Size
})
end
end)
NewOptionBtn.MouseButton1Click:Connect(function()
if CanClicksList[NewOptionBtn] then
--CanClicksList[NewOptionBtn] = false
print('c')
task.spawn(function()
Utils.Spring.target(NewOptionBtn, .35, 5, {
Size = UDim2.fromScale(NewOptionBtn.Size.X.Scale - .015, NewOptionBtn.Size.Y.Scale - .015)
})
task.delay(.2, function()
Utils.Spring.target(NewOptionBtn, .35, 5, {
Size = UDim2.fromScale(OptionButton.Size.X.Scale - .015, OptionButton.Size.Y.Scale - .015)
})
end)
end)
if typeof(OptionCallback) == 'function' then
OptionCallback()
end
end
end)
I’ve had this issue with MouseEnter and MouseLeave too. They’re highly unreliable.
Use this open source module. It fixed all my problems, and will likely fix all of yours too.
Yes. MouseEnter and MouseLeave sometimes just don’t fire despite the player’s mouse being clearly outside the bounds of the guiObject. Replacing your MouseEnter events with the module I linked’s events should solve this issue. It’s pretty easy to implement too, basically exactly like the native roblox MouseEnter/MouseLeave.
Yes… you’re correct!! I misdiagnosed the error here. Oops
It seems that the script sets the size of the guiObject .2 seconds after a click, probably to make the gui button get large then small again after clicked.
If the player moves their mouse away within these .2 seconds, it will bug out.
One solution could be to:
Check the size of the GuiObject in the delay(.2, function(), to ensure that it doesn’t set the guiObject’s size to too large.