Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by
zle_n 9
4 years ago
Edited 4 years ago

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?

0
Try replacing line 2 with: for index = 1, descendant in pairs(descendants) do nikoviking 236 — 4y

1 answer

Log in to vote
0
Answered by
zle_n 9
4 years ago

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.

Ad

Answer this question