Unknow amount of frames tweening

Hi guys, I’m trying to create a sort of “Self Check-In” for my airline. Here I use a surface gui that is put in playergui with the adornee set to the part. Now im coding in a local script inside this surface gui for making tween’s and buttons work. My goal is to be able to set an unknown amount of classes for this check-in. So when I then “check-in” a animation cycle will start and load the available classes with tweenservice tweening their transparency making a smooth cycle.

My issue so far is that i’m not sure the way I would code this, I have a module script that I set a certain amount of classes in. When the game is started it creates the amount of frames according to how many I set in the module script.

So far i’ve gotten:

MainFrame.beginBtn.MouseButton1Click:Connect(function()
	MainFrame.beginBtn:Destroy()
	local tif = TweenInfo.new(2,Enum.EasingStyle.Quad,Enum.EasingDirection.Out)
	local tif2 = TweenInfo.new(1,Enum.EasingStyle.Quad,Enum.EasingDirection.Out)

	local tw1 = tweenservice:Create(MainFrame.beginThing, tif, {BackgroundTransparency = 1})
	tw1:Play()
	local tw2 = tweenservice:Create(MainFrame.beginThing2, tif, {BackgroundTransparency = 1})
	tw2:Play()
	local tw3 = tweenservice:Create(MainFrame.begintxt, tif, {TextTransparency = 1})
	tw3:Play()
	wait(2)
	local tw4 = tweenservice:Create(CheckInFrame.AttributeFrame, tif2, {BackgroundTransparency = 0})
	tw4:Play()
	wait(1)
	local tw5 = tweenservice:Create(CheckInFrame.AttributeFrame.text, tif2, {TextTransparency = 0})
	tw5:Play()
	ClassFrames.ScrollBarImageTransparency = 0.5
	wait(1)
	local tw6 = tweenservice:Create(CheckInFrame.AttributeFrame, tif2, {BackgroundTransparency = 0})
	tw6:Play()
	wait(1)
	if sci.Classes == 1 then
		for i,v in pairs(ClassFrames.Class1Frame:GetDescendants()) do
			if v:IsA("Frame") then
				
			end
		end
	end
end)

This script contains the full function but the one im more interested in is the for i,v loop or if that even is possible to make work for this certain thing. I’m not sure if asking if there is 1 class it tweens in every part of that frame or how I would do it. Suggestions and resolvations would help extremly.

Please reply with something that could possibly help me. Feel free to ask questions if I’m unclear.

2 Likes

What exactly are the classes? When you say classes I’m thinking module scripts, but then that doesn’t make sense to me.

1 Like

Classes are the type of thing you check in as with an airline “Economy Class”, “Business Class”, etc.

2 Likes

So basically it’s just a frame with a lot of frames and text labels inside of it.

1 Like

So if I’m understanding correctly. You just need to tween the main class frame in the loop. The loop goes through each class. So just grab the current class setup the tween, play it and move to the next one.

1 Like

In a module script i set for example 5 classes. This triggers my already made script to make 5 frames with information and buttons of this class. (So a frame with a lot of children)

What I need is when I “open” the page. It tweens the transparency of each and everyone of those 5 classes to go to 0, either its background transparency or text transparency. I just need a smooth animation.

I suppose I don’t understand what the issue is. The main frame for each class contains all the elements so when you tween the transparency for that it should show or hide the children of that frame no?

1 Like

image
Here I have a scrolling frame where all the “classes” are being made. I want to tween the transparency of every element inside of the gui including every descendant or whatever. Then do this to every “Class(NR)Frame”

Okay. So then you’ll need to have a loop that grabs each classes frame. Then a subloop that grabs each descendant of that classes frame.
In the subloop, create a tween for each of the elements and either play them right away or put them into a table. SubTweens = {} After the sub loop finishes loop through the SubTweens table and play each tween.

Basically you either create and play the tween as you come across the element or you create the tween store it and play them all afterward.

I’m not really sure how I would do that, I dont have any experience with subloops.

At this moment this is what i’ve got:

for i,v in pairs(ClassFrames:GetChildren()) do
		if v:IsA("Frame") then
			for i,v in pairs(v:GetDescendants()) do
				
			end
		end
	end
for k,v in pairs(ClassFrames) do
    --This loop iterates over each class
    local elements = v:GetDescendants()
    for i = 1, #elements do
        --This loop interates over all the elements within the class.
    end
end

So I would add tween info and a supposedly tween of background transparency or something in the – This loop interates over all the elements?

Right, check if the transparency properties exists and if it does create a tween for it.

I’m sorry for being stupid but how would I search for the transparency feature? Like how would I search for Backgroundtransparency?

for k,v in pairs(ClassFrames) do
    --This loop iterates over each class
    local elements = v:GetDescendants()
    for i = 1, #elements do
        --This loop interates over all the elements within the class.
        if(elements[i].BackgroundTransparency)then
            --Create a tween for it and play it.
        end
    end
end

Is this correct?

for k,v in pairs(ClassFrames) do
		--This loop iterates over each class
		local elements = v:GetDescendants()
		for i = 1, #elements do
			--This loop interates over all the elements within the class.
			if(elements[i].BackgroundTransparency)then
				local tif2 = TweenInfo.new(1,Enum.EasingStyle.Quad,Enum.EasingDirection.Out)
				local twC = tweenservice:Create(elements[i], tif2, {BackgroundTransparency = 0})
				twC:Play()
			end
		end
	end
1 Like

I wasn’t sure if that was a table or instance so you have to do what you did before:

pairs(ClassFrames:GetChildren())
if v:IsA("Frame")then
for k,v in pairs(ClassFrames:GetChildren()) do
		if(not(v:IsA("Frame")))then continue end --Skip if not a frame
		--This loop iterates over each class
		local elements = v:GetDescendants()
		for i = 1, #elements do
			--This loop interates over all the elements within the class.
			if(elements[i].BackgroundTransparency)then
				local tif2 = TweenInfo.new(1,Enum.EasingStyle.Quad,Enum.EasingDirection.Out)
				local twC = tweenservice:Create(elements[i], tif2, {BackgroundTransparency = 0})
				twC:Play()
			end
		end
	end

Okay so, that seem to have worked. but it doesnt let me take the background transparency of the main object “Class1Frame”