Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Why does transparency on descendants only make one of each part transparent?

I made a transparency script for all parts in the workspace and I tried it the first time and it worked, but now it doesn't work, and I didn't change anything about the main function of the script


script.Parent.OnServerEvent:Connect(function(plr)
	local descendants = game.Workspace:GetDescendants() -- where all the parts are
	for index, descendant in pairs(descendants) do
		if descendant:IsA("BasePart") or descendant:IsA("Part") or descendant:IsA("UnionOperation") or descendant:IsA("TrussPart") then -- detects if the part is whatever it needs to be
			descendant.Transparency = 1 -- makes it transparent
			local a = game.ServerStorage["Purple Nebula"]:Clone()
			a.Parent = game.Lighting
				if game.Lighting.Sky then
					game.Lighting.Sky:Destroy()
					else
				end
				a.Parent = game.Lighting
				game.Lighting.TimeErase.Enabled = true
				script.Parent.Parent.Sounds.KCTheme:Play()
			end
	end
end)

My problem in detail is that I have Unions, Parts, and TrussParts in my map multiple of them, and so when I run the script only one of each gets transparent

I'm thinking that it has to do with the rest of the script, I don't know maybe too many things running in the same script at the same time?

Ex : I have 3 unions, and 5 parts in the workspace when I run the script only 1 of the unions gets transparent and 1 of the parts gets transparent.

Why is this happening?

1 comment

0

Try replacing line 2 with: for index = 1, descendant in pairs(descendants) do

1 answer

The problem with my code was that there was too many things running for it to handle so I just made separate events for all of them and now its working as intended.

This discussion is preserved as it was. New answers, comments, and votes are closed.