.Transparency value is not functioning in some cases

This script is really quite simple
It is a system of for loops all operating in time intervals to reveal a storm.
Some pieces are not working correctly however.
Script here:

local fldr = script.Parent.Parent.FolderC

task.wait(1)

for _, child1 in fldr:GetChildren() do
if child1.Name == “1” then
child1.Transparency = 0

	task.wait(10)
	
    for _, child2 in fldr:GetChildren() do
		if child2.Name == "2" then
			child2.Transparency = 0
			
		    task.wait(15)
            for _, child3 in fldr:GetChildren() do
				if child3.Name == "3" then
					child3.Transparency = 0
					
					task.wait(25)
					
                    for _, child4 in fldr:GetChildren() do
						if child4.Name == "4" then
							child4.Transparency = 0
							
							task.wait(15)
                            for _, child5 in fldr:GetChildren() do
								if child5.Name == "5" then
									child5.Transparency = 0
									
									task.wait(15)
									
                                    for _, child6 in fldr:GetChildren() do
										if child6.Name == "6" then
											child6.Transparency = 0
							
											script.Parent.formed = true
											
											print("done")
											
                                        end
                                    end
                                end
                            end
                        end
                    end
                end
            end
        end
    end
end

end

Model:
SRSCK-EARLY-25m4d5.rbxm (6.6 KB)

Can you be a little more clear with what you mean by “not working?”

Also, I’m not sure about the intensions of your script but having so many nested for loops is usually a pretty bad practice. What is 2, 3, 4, 5, 6? Why are the loops nested in each other instead of being separate? Do you have multiple 2’s 3’s, 4’s, etc. in fldr? Please provide more information.

Run the file for a bit, all invisible clouds should appear, but some clouds especially on the tail and updraft are not appearing,

2 3 4 5 6 are the stages of storm that are supposed to appear later on, and yes, i do have multiple.

i typed up a new one thats EVEN WORSE because NOTHING APPEARS. here is the script if you wanna fix that one instead also it has really deep nested for AND if loops so you might really hate it bc i made it before i saw this. sorrie!
anyways here its is


local RootDirectory = script.Parent.Parent

local Parent = script.Parent

local f = Parent.formed

function Form()
task.wait(1)

local CDirectory = RootDirectory:FindFirstChild("FolderC")

if CDirectory then
    for _, child in CDirectory:GetChildren() do
        if child.Name == "1" then
            child.Transparency = 0
        end
    end
end

end

function Form()
task.wait(10)

local CDirectory = RootDirectory:FindFirstChild("FolderC")

if CDirectory then
	for _, child in CDirectory:GetChildren() do
		if child.Name == "2" then
			child.Transparency = 0
		end
	end
end

end

function Form()
task.wait(10)

local CDirectory = RootDirectory:FindFirstChild("FolderC")

if CDirectory then
	for _, child in CDirectory:GetChildren() do
		if child.Name == "3" then
			child.Transparency = 0
		end
	end
end

end

function Form()
task.wait(15)

local CDirectory = RootDirectory:FindFirstChild("FolderC")

if CDirectory then
	for _, child in CDirectory:GetChildren() do
		if child.Name == "4" then
			child.Transparency = 0
		end
	end
end

end

function Form()
task.wait(10)

local CDirectory = RootDirectory:FindFirstChild("FolderC")

if CDirectory then
	for _, child in CDirectory:GetChildren() do
		if child.Name == "5" then
			child.Transparency = 0
		end
	end
end

end

function Form()
task.wait(5)

local CDirectory = RootDirectory:FindFirstChild("FolderC")

if CDirectory then
	for _, child in CDirectory:GetChildren() do
		if child.Name == "6" then
			child.Transparency = 0
		end
	end
end

end

sorry for the weirdness the script preview thingy hated me
also i stay up late

Couple of things.

  1. You should look into the CollectionService It’s very good for managing groups of instances. You would add tags to the parts to specify the stage they belong to.
  2. Look at putting repetitive code into functions so something like
local function showParts(parts)
    for _, part in pairs(parts) do
        part.Transparency = 0
    end
end

that you could use like

showParts(CollectionService:GetTagged("stage1"))
task.wait(20)
showParts(CollectionService:getTagged(stage2"))
...

thats cool, i will try to use these tips. one question, do you use the local functions over and over or put a bunch of seperatte forloops in the function? and about the showparts thing if it is a local function over and over then do i do like showparts showparts2 or

You would really combine the two pieces.
functions and CollectionService.

the local showParts function just takes an array of parts as a parameter and sets the Transparency for all of them.
Then you use the CollectionService to get all of the parts tagged for each stage to call the showParts function with whenever it’s time to show that stage.

That’s what the example of what it might look like was showing

showParts(CollectionService:GetTagged("stage1"))
task.wait(20)
showParts(CollectionService:getTagged("stage2"))
task.wait(20)
showParts(CollectionService:getTagged("stage3"))

But the parts are named in stages so each one named like that needs to be de tranparencized like
1 1 1
2 2
3 3 3 3
4
5 5 5
6
Thats the reason for things like

local CDirectory = RootDirectory:FindFirstChild("FolderC")

if CDirectory then
	for _, child in CDirectory:GetChildren() do
		if child.Name == "5" then
			child.Transparency = 0
		end
	end
end

And

for _, child2 in fldr:GetChildren() do
		if child2.Name == "2" then
			child2.Transparency = 0

That’s what using Tags and the CollectionService would save you from doing. Instead of going off of the name it would be going off the tag for what stage they belong to.
It would be similar to if you had the parts for each stage in their own folder and you just passed the folder for the stage to the showParts function.
Just something where you don’t need to iterate over everything looking for specific names.

Fixed it by tinkering and making a new one from scratch with a stage system.
here it is

local Pa = script.Parent
local S1 = Pa.Stage1
local S2 = Pa.Stage2
local S3 = Pa.Stage3
local S4 = Pa.Stage4
local S5 = Pa.Stage5
local S6 = Pa.Stage6
local S7 = Pa.Stage7
local S8 = Pa.Stage8

task.wait(0.1)


	S1.s12.Transparency = 0
S1.s1.Transparency = 0

task.wait(10)


	S2["2"].Transparency = 0 


task.wait(10)


	S3["3"].Transparency = 0


task.wait(10)

-- Use table.foreEach to apply transparency without explicit loop
table.foreach(S4:GetChildren(), function(_, child)
	if child:IsA("BasePart") then
		child.Transparency = 0
	end
end)

task.wait(7)

table.foreach(S5:GetChildren(), function(_, child)
	if child:IsA("BasePart") then
		child.Transparency = 0
	end
end)

table.foreach(S6:GetChildren(), function(_, child)
	if child:IsA("BasePart") then
		child.Transparency = 0
	end
end)

task.wait(10)


	S7["7"].Transparency = 0


task.wait(3)


	S8["8"].Transparency = 0


task.wait(0.01)

script.Parent.scriptsFolder.Formed = true

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