Whenever the script runs, it displays the error ‘Workspace.rooms.cogworld.bomb rain:5: invalid argument #2 to ‘random’ (interval is empty)’ after a few seconds and stops running. Does anyone know how to fix this?
while true do
wait(1)
local children = script.Parent.bombs:GetChildren()
if(children == nil) then break end
local M = math.random(1,#children)
droplet = children[M]:Clone()
droplet.Parent = game.Workspace
droplet.Anchored = false
droplet.Transparency = 0
end
Maybe try printing the children inside the script?
Edit: It is definitely an issue with the children part here. I get the same error message when putting 0 instead of #children. That is the only time I get an error, and :GetChildren() only returns tables with the minimum value being 0. I did this in console:
And what if you print #children? Also is this supposed to run when #children == 0 at any point? Like it might work the first few times that #children ~= 0, but after that it will probably break and error. Did it error out when you did this printing?
It’s counting down from the amount of children in the folder, and when it reaches 0, it ends. I don’t know why, because I am obviously cloning the object and not taking it out of the folder.