["Random_Burst"] = {
Description = "",
Function = function(pyroName)
local tblOfPyro = {}
for _,Item in game.Workspace:FindFirstChild("Pyrotechnics"):GetDescendants() do
if Item:IsA("Model") and string.lower(Item.Name) == string.lower(pyroName) then
table.insert(tblOfPyro,Item)
end
end
for _,Pyro in pairs(tblOfPyro) do
coroutine.wrap(function()
for _,Item in Pyro:GetDescendants() do
coroutine.wrap(function()
if Item:IsA("Sound") then
Item:Play()
end
if Item:IsA("ParticleEmitter") and string.lower(Item.Name) == "p1" then
Item.Enabled = true
task.wait(.3)
Item.Enabled = false
end
end)()
task.wait(.05)
end
end)()
end
end,
}
If it’s number-indexed, sort it with random numbers.
local parts = parent:GetChildren()
local max = #parts
local generator = Random.new()
table.sort(parts, function(_a, _b)
return generator:NextInteger(1, 10) > generator:NextInteger(1, 10)
end)
table.sort() sorts a table based on what is returned in the sorter function. true returned means the elements should be swapped, false means they should not.
Random.new() is a more updated pseudorandom generator. It’s like math.random(). the NextInteger() function returns a random integer between 1 and 10.
For each two elements in the table, the function passed to table.sort is applied. By comparing two random numbers, we are essentially creating a random chance the elements will be swapped. Following this method, we are randomly swapping the order of elements within the table.
Please let me know if you have any more questions regarding my code.