I’m trying to script something similar to hovering over a card in uno and it pops up, and if you click it, it stays up, but whenever I click the button, it pops back down because of the mouse leaving after clicking the button. How do I fix this?
My script:
local dividers = script.Parent
local tabs = dividers:GetChildren()
local tweenS = game:GetService("TweenService")
for i, tab in pairs(tabs) do
if tab:IsA("TextButton") then
local ogSize = tab.Size
tab.MouseEnter:Connect(function()
local info = TweenInfo.new(
0.5,
Enum.EasingStyle.Quint,
Enum.EasingDirection.InOut,
0,
false,
0
)
local goal = {
Size = UDim2.fromScale(tab.Size.X.Scale, 1.505)
}
local anim = tweenS:Create(tab, info, goal)
anim:Play()
end)
tab.MouseLeave:Connect(function()
local info = TweenInfo.new(
0.5,
Enum.EasingStyle.Quint,
Enum.EasingDirection.InOut,
0,
false,
0
)
local goal = {
Size = ogSize
}
local anim = tweenS:Create(tab, info, goal)
anim:Play()
end)
tab.MouseButton1Down:Connect(function()
for i, frame in dividers:GetChildren() do
if frame:IsA("Frame") then
frame.Visible = false
print(frame, tab)
tab.Size = UDim2.fromScale(tab.Size.X.Scale, 1.047)
if frame.Name == tab.Name.. "Frame" then
print(frame, tab)
frame.Visible = true
tab.Size = UDim2.new(0.156, 0, 1.505, 0)
end
end
end
end)
end
end