I have this script, it works, but all of the Aliens spawn at “0, 0, 0” and at the same spot, They also attack each other. How would I make the aliens spawn randomly around the surface of the map, and not attack each other??
local Alien = game.ServerStorage.Alien
local AlienAmount = 300
local SpawnedAliens = {}
local AlreadySpawned = false
while true do
if (game.Lighting.ClockTime < 5 or game.Lighting.ClockTime > 18) and not AlreadySpawned then
AlreadySpawned = true
for i = 1, AlienAmount do
local AlienClone = Alien:Clone()
AlienClone.Parent = workspace
table.insert(SpawnedAliens, AlienClone)
wait(0.25)
end
elseif not (game.Lighting.ClockTime < 5 or game.Lighting.ClockTime > 18) and AlreadySpawned == true then
if #SpawnedAliens > 0 then
for i,v in pairs(SpawnedAliens) do
if v ~= nil then
v:Destroy()
end
end
end
AlreadySpawned = false
end
wait(1)
end
local Alien = game.ServerStorage.Alien
local AlienAmount = 300
local SpawnedAliens = {}
local AlreadySpawned = false
while true do
if (game.Lighting.ClockTime < 5 or game.Lighting.ClockTime > 18) and not AlreadySpawned then
AlreadySpawned = true
for i = 1, AlienAmount do
local AlienClone = Alien:Clone()
AlienClone:SetPrimaryPartCFrame(CFrame.new(Vector3.new(math.random(50,500), 0, math.random(50, 500))))
AlienClone.Parent = workspace
table.insert(SpawnedAliens, AlienClone)
wait(0.25)
end
elseif not (game.Lighting.ClockTime < 5 or game.Lighting.ClockTime > 18) and AlreadySpawned == true then
if #SpawnedAliens > 0 then
for i,v in pairs(SpawnedAliens) do
if v ~= nil then
v:Destroy()
end
end
end
AlreadySpawned = false
end
wait(1)