CanvasGroupTransparency value change does not working

I wanted a Frame and it’s childs to fade so easy solution is CanvasGroup…
i make it change GroupTransparency on a normal ScreenGui and it works!
but i wanted that for a plugin that i am working on…
and it did not worked on same frame with the same code but on DockWidgetGui…
one of the key things is its shown at right transparency when setted by hand even before saving AsLocalPlugin
but at run time tweening or direct setting not worked for me…
i am using up to date version of studio.

i dont think any code sample is necesary.
but here is my code.

UIUtilsModule same on both plugin and screen Gui

local TweenService = game:GetService("TweenService")

local UIUtils = {}

-- General tween creator
UIUtils.TweenProperty = function (Object: GuiObject, GoalProperties, Time: number, EasingStyle: Enum.EasingStyle, EasingDirection: Enum.EasingDirection)
	if not Object or not Object:IsA("GuiObject") then warn("UIUtils : didn't pass a valid Gui Object!") return end
	if not GoalProperties then warn("UIUtils : didn't pass a valid Goal Properties!") return end
	local tweenInfo = TweenInfo.new(Time or 0.3, EasingStyle or Enum.EasingStyle.Quad, EasingDirection or Enum.EasingDirection.InOut)
	local tween = TweenService:Create(Object, tweenInfo, GoalProperties)
	tween:Play()
	return tween
end

UIUtils.TweenCanvasGroupTransparency = function (CanvasGroup: CanvasGroup, TargetTransparency: number , Duration: number)
	if not CanvasGroup or not CanvasGroup:IsA("CanvasGroup") then warn("UIUtils : didn't pass a valid Canvas Group!") return end
	return UIUtils.TweenProperty(CanvasGroup, {GroupTransparency = TargetTransparency}, Duration or 0.1)
end

UIUtils.TweenSize = function (Object: GuiObject, TargetSize: UDim2, Duration: number)
	if not Object or not Object:IsA("GuiObject") then warn("UIUtils : didn't pass a valid Gui Object!") return end
	return UIUtils.TweenProperty(Object, {Size = TargetSize}, Duration or 0.2)
end

return UIUtils

this is the localScript that is working (with screenGui)

local UserInputService = game:GetService("UserInputService")
local UIUtils = require(script.UIUtils)
local MiniPromptContainer = script.Parent.MiniPromptContainer
local MiniPrompt = MiniPromptContainer.MiniPrompt

local isVisible = false

UserInputService.InputBegan:Connect(function(input)
	if input.KeyCode == Enum.KeyCode.E then
		isVisible = not isVisible
		Togle()
	end
end)

function Togle()
	if isVisible == true then
		--[[ Make Container Visible ]]
		MiniPrompt.Parent.Visible = true

		--[[ Tween Mini Prompt Size To Original ]]
		local tween: Tween = UIUtils.TweenSize(MiniPrompt, UDim2.fromScale(0.5, 0.7), 0.2)

		if tween then tween.Completed:Connect(function()
				UIUtils.TweenCanvasGroupTransparency(MiniPrompt.MainContent, 0, 0.2) 
			end)
		end
	else
		--[[ Tween Mini Prompt Size To Closed ]]
		UIUtils.TweenCanvasGroupTransparency(MiniPrompt.MainContent, 1, 0.1)
		local tween: Tween = UIUtils.TweenSize(MiniPrompt, UDim2.fromScale(0, 0), 0.2)

		--[[ Make Container Invisible]]
		if tween then tween.Completed:Connect(function()
				MiniPrompt.Parent.Visible = false
			end)
		end
	end
end

and last that the code on plugin a module miniPromptController

local MiniPromptController = {}
--[[ Get Reference To UIUtils ]]
local UIUtils = require(script.Parent.UIUtils)
--[[ Hold Reference To Mini Prompt ]]
local MiniPrompt : Frame = nil
--[[ Hold Reference To Toggle Bool ]]
local isVisible = false

MiniPromptController.Initialize = function (container)
	if not container then warn("Mini Prompt Controller : didn't pass a valid container!") return end
	container.Visible = false
	MiniPrompt = container.MiniPrompt
	
	--[[ Set Canvas Group Transparency To 1 ]]
	MiniPrompt.MainContent.GroupTransparency = 1
	--[[ Set Mini Prompt Size To 0 ]]
	MiniPrompt.Size = UDim2.fromScale(0,0)
end

MiniPromptController.toggle = function ()
	isVisible = not isVisible
	MiniPromptController.acceptToggle()
end

MiniPromptController.acceptToggle = function ()
	if isVisible == true then
		--[[ Make Container Visible ]]
		MiniPrompt.Parent.Visible = true
		
		--[[ Tween Mini Prompt Size To Original ]]
		local tween: Tween = UIUtils.TweenSize(MiniPrompt, UDim2.fromScale(0.5, 0.7), 0.2)

		if tween then tween.Completed:Connect(function()
				UIUtils.TweenCanvasGroupTransparency(MiniPrompt.MainContent, 0, 0.2) 
			end)
		end
	else
		--[[ Tween Mini Prompt Size To Closed ]]
		UIUtils.TweenCanvasGroupTransparency(MiniPrompt.MainContent, 1, 0.1) 
		local tween: Tween = UIUtils.TweenSize(MiniPrompt, UDim2.fromScale(0, 0), 1)
		
		--[[ Make Container Invisible]]
		if tween then tween.Completed:Connect(function()
				MiniPrompt.Parent.Visible = false
			end)
		end
	end
end

return MiniPromptController

Here is the MiniPrompt Layout in Explorer.
MiniPromptInExplorer
Here is Plugin version.
PluginVersionMiniPromptInExplorer

i double checked every thinkable error:
-wrong refrence
-wrong check filter
-typo
-timing

idk what else?
you may think maybe on plugin side initialize function is repeatedly called but thats not the case and even if it was it is telling it(canvasGrop) to become transparent… it is not becoming transparent.

please recreate the system on a dockwidgetGui in a local plugin and tell me what i am doing wrong.

do you mind try the following: when you create the DockWidgetPluginGui, explicitly set its ZIndexBehavior to be Sibling?

1 Like

thank you! its working now i never knew about zIndexBehaivor before!

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.