Hey working on a module to spawn a cow but it is being stupid like its making an error but the script works i just want the error gone here is my code
local cow = {}
function cow.summon(pos, groupAMM)
for _ = 1, groupAMM do
local Cow = script.Parent.Mobs.Rig:Clone()
Cow.Parent = workspace
Cow:SetPrimaryPartCFrame(CFrame.new(pos.X + math.random(-5, 5), pos.Y, pos.Z + math.random(-5, 5)))
spawn(function()
while true do
if cycles == 50 then
Cow:Destroy()
print("Mob cap hit; despawning and breaking loop.")
break
else
cycles = 1
local PositionToMoveTo = Vector3.new(Cow.HumanoidRootPart.Position.X + math.random(-10, 10), Cow.HumanoidRootPart.Position.Y, Cow.HumanoidRootPart.Position.Z + math.random(-10, 10))
Cow.Humanoid:MoveTo(PositionToMoveTo)
wait(math.random(0, 2))
cycles += 1
end
end
end)
end
end
return cow
EDIT: i would still like help on this