I need help with math.random

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
1 Like

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.

1 Like

yeah ill be looking over the script and understand it better so i hopefully wont need help next time

RandomTest.rbxl (25.0 KB)