I have buttons using these functions and I was having problems with mouseleave because it doesn’t sometimes tween the button back. I found a module from here and used it, but still having the same issues.
Code:
local MouseOverModule = require(game.ReplicatedStorage.MouseOverModule)
local MouseEnter, MouseLeave = MouseOverModule.MouseEnterLeaveEvent(script.Parent)
MouseEnter:Connect(function()
script.Parent.Parent.Parent.Sounds.Hover:Play()
script.Parent:TweenSize(UDim2.new(0.041, 0,0.094, 0), "In", "Linear", 0.1)
end)
MouseLeave:Connect(function()
script.Parent:TweenSize(UDim2.new(0.037, 0,0.087, 0), "In", "Linear", 0.1)
end)
script.Parent.MouseButton1Click:Connect(function()
if script.Parent.Parent.Parent.Shop.Visible ~= true then
script.Parent.Parent.Parent.Sounds.Click:Play()
wait(0.1)
script.Parent.Parent.Parent.Shop.Visible = true
script.Parent.Parent.Parent.Sounds.Open:Play()
script.Parent.Parent.Parent.Shop:TweenSize(UDim2.new(0.497, 0, 0.708, 0), "In", "Linear", 0.3)
wait(0.3)
for i,v in pairs(script.Parent.Parent.Parent.Shop.Frame:GetChildren()) do
if v:IsA("ImageButton") then
v.Visible = true
end
end
for i,v in pairs(script.Parent.Parent.Parent.Shop.Frame:GetChildren()) do
if v:IsA("ScrollingFrame") and v.Name == "WeaponsFrame" then
v.Visible = true
end
end
game.Lighting.Blur.Enabled = true
game.Workspace.Camera.FieldOfView = 80
end
end)