How do i make a “DogTask” work in two groups in one loop?
Here’s my script so far
local DogTask = require(8068106347)
for i,v in pairs(workspace.NEXUSBEAMS:GetChildren()) do
DogTask.WrapDogTask(function()
while true do
wait(math.random())
script.Parent.Parent.Events.ONSPEC:Fire("b", tonumber(v.Name:sub(-1,-1)))
wait(.01)
script.Parent.Parent.Events.OFFSPEC:Fire("b", tonumber(v.Name:sub(-1,-1)))
wait(.01)
end
end,"")
end
I want it to look for children in two groups, in the same loop.
like
for i,v in pairs(workspace.NEXUSBEAMS.GROUPA:GetChildren()) do
and
for i,v in pairs(workspace.NEXUSBEAMS.GROUPB:GetChildren()) do
I’m sorry if it sounds confusing.
Use a function for it, passing v as an argument
GetDescendants
local Stuff = workspace.NEXUSBEAMS:GetDescendants()
for i, v in pairs(Stuff) do
if Stuff.Parent ~= workspace.NEXUSBEAMS then
DogTask.WrapDogTask(function()
while true do
wait(math.random())
script.Parent.Parent.Events.ONSPEC:Fire("b", tonumber(v.Name:sub(-1,-1)))
wait(.01)
script.Parent.Parent.Events.OFFSPEC:Fire("b", tonumber(v.Name:sub(-1,-1)))
wait(.01)
end
end,"") -- what
end
end
Use table.move
local groupA = workspace.NEXUSBEAMS.GROUPA:GetChildren()
local groupB = workspace.NEXUSBEAMS.GROUPB:GetChildren()
local combined = table.move(groupA, 1, #groupA, #groupB + 1, groupB)
-- Move indices 1 through the end of groupA (#groupA) into the next index of groupB
-- Basically adding all of groupA's contents to the end of groupB, making one table with everything in it
Now use combined in the for loop.