i’m trying to remove all the parts from a model names tile
Can you show a picture of explorer and tell me which parts you’re trying to destroy
and there are 400 total tiles that its choosing from
i put them into the script to avoid any issues with getchildren() and folders
if v.Name=="Tile" then
yeah but it still needs to go through and check the folders if they are located in the same spot of hierarchy, therefore breaking the script
I think something like this? I’m not entirely sure because I’m still confused on what you’re trying to do.
Iterate over all of the children then iterate over their children.
local TileModels = script:GetDescendants()
local Tiles = {}
for i, Tile in pairs(Tiles) do
local Parts = Tile:GetChildren()
for j, Part in pairs(Parts) do
table.insert(Tiles, Part)
end
end
while (#Tiles > 0) do
local Index = math.random(1, #Tiles)
Tiles[Index]:Destroy()
table.remove(Tiles, Index)
wait(1)
end
i tried the script and its not destroying the tiles anymore for some reason
im just trying to destroy tiles one model at a time which are located inside the script
Oh, okay. Try something like this.
local Tiles = script:GetChildren()
for i, Tile in pairs(Tiles) do
local Parts = Tile:GetChildren()
while (#Parts > 0) do
local Index = math.random(1, #Parts)
Parts[Index]:Destroy()
table.remove(Parts, Index)
wait(1)
end
end
It will iterate through each model, then randomly remove parts in that model until it has no more parts, then it will move onto the next tile model.
it seems to be choosing the models based on creation date cause its not removing them from the model and i want the deletion of models to be instant, with the said model being what is randomized
function SortRandom(Objs)
local sorted = {}
local Taken = {}
for Index, Value in pairs(Objs) do
local function Sort()
local RandomSlot = math.random(1, #Objs)
if Taken[RandomSlot] == nil then
Taken[RandomSlot] = true
sorted[RandomSlot] = Value
else
Sort()
end
end
Sort()
end
return sorted
end
for _, Value in pairs(SortRandom(workspace.Folder:GetChildren())) do
Value:Destroy()
wait(1)
end
im sorry if im asking for too much lol im just kinda new to this
Are you trying to delete all of the parts inside each Tile
? All of them instantly? And then wait 1 second before choosing a new tile’s children to delete?
yeah thats what im going for with this minigame
local Tiles = script:GetChildren()
while (#Tiles > 0) do
local Index = math.random(1, #Tiles)
local Tile = table.remove(Tiles, Index)
Tile:ClearAllChildren()
wait(1)
end
thank you so much and sorry for probably bothering you about something thats pretty simple lol
No problem. Part of the devforum is to get help with your issues or to help others with theirs.
yeah ill be looking over the script and understand it better so i hopefully wont need help next time