Once again, I’m making yet another game. At this point I should probably just stick with one.
Anyways, I’m attempting to check all the children of a group. However, on the second time (after I clear the group) it shuts down the script because there are no children in the folder.
Here’s the code. The failure is at the GetChildren() line
while wait() do
local boxes = script.Parent:GetChildren("Box")
if #boxes >= 12 then
print("resetting map")
game.Workspace.failGUIevent:FireAllClients()
print("sending message...")
local maps = game.ReplicatedStorage.Maps:GetChildren()
local map = game.Workspace.Map:GetChildren()
game.Lighting.Blur.Size = 50
for i = 1, #map do
local maptomoveback = map[i]
maptomoveback.Parent = game.ReplicatedStorage.Maps
end
for box = 1, #boxes do
local b = boxes[box]
b:Destroy()
end
game.Workspace.Failure:Play()
wait(3)
game.Workspace.FailTheme:Play()
wait(16)
local newmapnum = math.random(1, #maps)
local newmap = maps[newmapnum]
newmap.Parent = game.Workspace.Map
game.Lighting.Blur.Size = 2
game.Workspace.BoxesDelivered.Value = 0
game.Workspace.FailTheme:Stop()
game.Workspace.FailTheme.TimePosition = 0
end
end
I understand what I need to do, but I don’t know how to go about doing it.