Hello i have text buttons inside of a UIGridLayout and i want it to grow when hovering over it. So to achieve this i clone the button then parent it to itself because i can’t change the size of a button parented to a UIGridLayout but the problem is the original button doesn’t get activated when you click on it
Here’s the code :
for i, weaponShopButton: TextButton in pairs(CollectionService:GetTagged("WeaponShopButton")) do
local placeholderButton = nil
local shrinkTween: Tween = nil
local growTween: Tween = nil
weaponShopButton.MouseEnter:Connect(function()
if shrinkTween then
shrinkTween:Cancel()
shrinkTween = nil
else
placeholderButton = weaponShopButton:Clone()
placeholderButton.Parent = weaponShopButton
end
placeholderButton.Size = UDim2.new(1,0,1,0)
local uiGradient: UIGradient = placeholderButton:WaitForChild("UIGradient")
uiGradient.Offset = Vector2.new(-1, 0)
growTween = TweenService:Create(placeholderButton,TweenInfo.new(0.3,Enum.EasingStyle.Quad,Enum.EasingDirection.InOut),{Size = UDim2.new(1.2,0,1.2,0)})
growTween:Play()
local slideEffect = TweenService:Create(uiGradient,TweenInfo.new(1,Enum.EasingStyle.Quad,Enum.EasingDirection.InOut),{Offset = Vector2.new(5,0)})
slideEffect:Play()
end)
weaponShopButton.MouseLeave:Connect(function()
if growTween then
growTween:Cancel()
end
shrinkTween = TweenService:Create(placeholderButton,TweenInfo.new(0.3,Enum.EasingStyle.Quad,Enum.EasingDirection.InOut),{Size = UDim2.new(1,0,1,0)})
shrinkTween:Play()
shrinkTween.Completed:Connect(function(playbackState)
if playbackState == Enum.PlaybackState.Cancelled then return end
placeholderButton:Destroy()
shrinkTween = nil
end)
end)
weaponShopButton.Activated:Connect(function()
print("Activated") -- Does not print
--Random stuff
end)
end