I want this script to remove the "ClassName" From the "ClassList" m[i] Fails To read the ClassList and comes with an error
Unless there is another way to do this?
01 | while true do |
02 | wait( 1 ) |
03 | local m = script.Parent:GetChildren() |
04 | for i = 1 , #m do |
05 |
06 | classlist = { "Sky" , "BloomEffect" , "BlurEffect" , "ColorCorrectionEffect" , "SunRayEffect" } |
07 | --Classlist the stuff that wants to get removed |
08 |
09 | if m [ i ] .className = = classlist then |
10 | m [ i ] :Remove() |
11 |
12 | end |
13 |
14 | end |
15 | end |
01 | while true do |
02 | wait( 1 ) |
03 | local m = script.Parent:GetChildren() |
04 | for i = 1 , #m do |
05 |
06 | classlist = { "Sky" , "BloomEffect" , "BlurEffect" , "ColorCorrectionEffect" , "SunRayEffect" } |
07 | --Classlist the stuff that wants to get removed |
08 | for j = 1 ,#classlist do |
09 | if m [ i ] .className = = classlist [ j ] then |
10 | m [ i ] :Remove() |
11 | end |
12 | end |
13 | end |
14 | end |
So the problem is you have to create a nested for loop because you can't just have a single class name equal to an entire table. It will check if m[0] is equal to classlist[0 through 5] before going to m[1].
Try using adding another for loop to check if the name of the current className is in the class list: for j=1, #classlist do if m[i].ClassName == classlist[j] then m[i]:Remove() end end