Hello, I am having a problem with a script and I am not entirely sure what is causing it.
Basically, I want this script to make a bunch of clones in somewhat random locations. Which it does perfectly for a little bit. Although, after a couple times through the loop, it starts to only clone parts of the model, particularly one part and the scripts, that's it.
It doesn't clone the rest of the model.
I cannot figure out what might be wrong.
function _M.clones(animal)
while _M.start do
wait(.5)
--Problem area from here...
for x= math.random(2),0,-1 do
wait(.4)
animal = animal:Clone()
wait()
animal.Parent = game.Workspace
animal:MakeJoints()
animal:MoveTo(Vector3.new(math.random(175), 250, math.random(225)))
--To here...
local Colors = animal:GetChildren()
local color = BrickColor.new(math.random(),math.random(),math.random())
--Just here to randomize color.
for i = 1, #Colors do
if Colors[i].ClassName == "Part" and Colors[i].BrickColor.Name ~= "Pink" then
Colors[i].BrickColor = color
end
end
end
end
end
I would like to mention that this function is present in a Module script, not sure if that would change anything but I figured it is worth mentioning.
Let me know if you can find anything or at least give me an idea of what might going on.
Thanks!

1 comment
Think I just spotted it, logical error...I will post the fix after I test