Trying to randomly delete all parts of a model in no particular order, by fading them out then removing them with destroy(), but the code doesn't seem to be executing and am completely blank.
house = workspace.SuburbanHome function _G.findRandomChild(model) return model:children()[math.random(1,#model:children())] end function destroyItem(part) for x = 1, 10 do nextRandom.transParency = nextRandom.Transparency - .1; wait() if nextRandom.transParency == 0 then nextRandom:Destroy() end end end for i =1, 10,000 do nextRandom = findRandomChild(house) destroyItem(nextRandom) end
There are some typos and problems with your script, but I appreciate the effort you put in.
I kind of dislike how you did this, as it is confusing for me, so I'm going to remake your whole script to make it more simple and understandable. I'll explain how it works below the code block.
local model = workspace:WaitForChild('Model') while wait(.1) do local modeltable = model:GetDescendants() -- Change to :GetChildren() if you don't want descendants destroyed. if #modeltable == 0 then break end local randompick = modeltable[math.random(#modeltable)] if randompick:IsA('BasePart') then for i = randompick.Transparency, 1, .1 do wait() randompick.Transparency = i end randompick:Destroy() end end print('Broke')
I decided to do this in a loop. Every .1 seconds, the script gets the descendants and checks if there are any parts in the model. If there is, it'll continue, otherwise it'll break the whole loop and move on to the print. The script picks a random part through "randompick", checks if it actually a part, then changes its transparency to 1 based on the part's transparency (it'll make it look smoother now if any of your parts are already transparent). After it finishes making the part invisible completely, it'll destroy it. Then the loop makes the whole thing repeat until there are no parts left in the model.
Hope this helped!