Problem with CanvasGroup

CanvasGroup it not working when I start click button and changed anything

-- Important Service
local Tweenservice = game:GetService("TweenService")
local StarterguiService = game:GetService("StarterGui")

local TeamGUI = game.StarterGui.Team.CanvasGroup
local Btn = script.Parent

TeamGUI.GroupTransparency = 1
TeamGUI.Size = UDim2.new(0,0,0,0)

local isOpen = false


local tweenInfo = TweenInfo.new( 0.5, Enum.EasingStyle.Quint, Enum.EasingDirection.InOut )

local OpenGoal = { Size = UDim2.new(1,0,1,0), GroupTransparency = 0 }
local CloseGoal = { Size = UDim2.new(0,0,0,0), GroupTransparency = 1 }

-- Tween open and close
local function TweenOpenClose()
	if isOpen then
		isOpen = false
		local Close = Tweenservice:Create(TeamGUI, tweenInfo, CloseGoal)
		Close:Play()
		Close.Completed:Connect(function()
			print("Close succ!")
		end)
	else
		isOpen = true
		local Open = Tweenservice:Create(TeamGUI, tweenInfo, OpenGoal)
		Open:Play()
		Open.Completed:Connect(function()
			print("Open succ!")
		end)
    end
end


Btn.MouseButton1Click:Connect(TweenOpenClose)```

Do the messages get printed? IIRC there is an issue where canvas groups break if their size is 0 even in 1 axis, so that might be it.

1 Like