Hiding main buttons when opening a frame

Hello, I’ve followed a tutorial to make a frametrigger script (here it is: How to make an animated UI frame opening and closing module! - YouTube) but I want to add something else and I have no idea how, I tried to do it on my own but it didn’t work.
Basically, I want that when a frame opens like Shop, it hides all the frames in a screengui called “Main”:
image
Here you can see that I have one frame called “PetUI” and 2 frames in “Main” called Pets and Stats.
The “Pets” frame has a button and when it’s clicked it opens the “PetUI” frame, I want it to also hide “Pets” and “Stats”
How can I do that? I already created a function in FrameTrigger, here is the script:

local module = {}
--// Services
local tweenService = game:GetService("TweenService")
local frames = script.Parent:WaitForChild("Frames")
local main = script.Parent:WaitForChild("Main")

local frameOpenSpeed = 0.6
local frameCloseSpeed = 0.2
local frameOpenEasingStyle = Enum.EasingStyle.Back
local frameOpenEasingDirection = Enum.EasingDirection.Out
local frameClosingEasingStyle = Enum.EasingStyle.Sine
local frameClosingEasingDirection = Enum.EasingDirection.Out

function module.CloseFrame(frameName)
	local frame = frames:FindFirstChild(frameName)
	if frame then
		local closeTween = tweenService:Create(frame,
			TweenInfo.new(frameCloseSpeed, frameClosingEasingStyle, frameClosingEasingDirection),
			{Size = UDim2.fromScale(0, 0)}
		)
		closeTween:Play()
		closeTween.Completed:Connect(function()
			frame.Visible = false
		end)
	end
end

function module.CloseAllFrames()
	for _, frame in pairs(frames:GetChildren()) do
		if frame:IsA("Frame") then
			coroutine.wrap(module.CloseFrame)(frame.Name)
		end
	end
end

function module.HideAllFrames()
	
end

function module.SeeAllFrames()
	
end

function module.OpenFrame(frameName)
	module.CloseAllFrames()
	module.HideAllFrames()
	
	local frame = frames:FindFirstChild(frameName)
	if frame then
		frame.Size = UDim2.fromScale(0, 0)
		task.wait(frameCloseSpeed + 0.1)
		frame.Visible = true
		
		local openTween = tweenService:Create(frame,
			TweenInfo.new(frameOpenSpeed, frameOpenEasingStyle, frameOpenEasingDirection),
			{Size = UDim2.fromScale(1, 1)}
		)
		
		openTween:Play()
	end
end

return module

The HideAllFrames function is enabled when a frame opens and the SeeAllFrames function is enabled when the frame closes.
Thanks for anyone who can help me, if you need to contact me feel free to add me one discord: Xera#0326

Anybody can help me please? It’s really important

local module = {}
--// Services
local tweenService = game:GetService("TweenService")
local frames = script.Parent:WaitForChild("Frames")
local main = script.Parent:WaitForChild("Main")

local frameOpenSpeed = 0.6
local frameCloseSpeed = 0.2
local frameOpenEasingStyle = Enum.EasingStyle.Back
local frameOpenEasingDirection = Enum.EasingDirection.Out
local frameClosingEasingStyle = Enum.EasingStyle.Sine
local frameClosingEasingDirection = Enum.EasingDirection.Out

function module.CloseFrame(frameName)
    module.SeeAllFrames()
    local frame = frames:FindFirstChild(frameName)
    if frame then
        local closeTween = tweenService:Create(frame,
            TweenInfo.new(frameCloseSpeed, frameClosingEasingStyle, frameClosingEasingDirection),
            {Size = UDim2.fromScale(0, 0)}
        )
        closeTween:Play()
        closeTween.Completed:Connect(function()
            frame.Visible = false
        end)
    end
end

function module.CloseAllFrames()
    for _, frame in pairs(main:GetDescendants()) do
        if frame:IsA("Frame") then
            frame.Visible = false
        end
    end
end

function module.HideAllFrames()
    
end

function module.SeeAllFrames()
    
end

function module.OpenFrame(frameName)
    module.CloseAllFrames()
    module.HideAllFrames()
    
    local frame = frames:FindFirstChild(frameName)
    if frame then
        frame.Size = UDim2.fromScale(0, 0)
        task.wait(frameCloseSpeed + 0.1)
        frame.Visible = true
        
        local openTween = tweenService:Create(frame,
            TweenInfo.new(frameOpenSpeed, frameOpenEasingStyle, frameOpenEasingDirection),
            {Size = UDim2.fromScale(1, 1)}
        )
        
        openTween:Play()
    end
end

return module
2 Likes

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