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
You do have an alien in ServerStorage, correct? And make sure it isn’t invisible or anything like that, worth it to double check. Screenshots are helpful.
Thats not the issue, it is changing the value back to false (usually it will be true because of the if statement before it, and it doesn’t matter regardless)
I would check the opacity of the alien and make sure the location is set to origin and anchored (or not, depending). Could you also screenshot the console output when running the game?
edit: Also check the clocktime and make sure it is the correct value, I am not familiar with it but if that is the wrong value the first if statement won’t trigger at all.
I found and fixed the problem, the new problem is that the aliens are spawning in the same spot, and attacking themselves. How do I make them spawn randomly
You would need to define several spawn points and loop through each alien, choosing a spawn point randomly. You could put the spawn points in a table, and use that. If you only want one alien per spawn, remove the spawn from the table once you spawn the alien. You don’t have to use tables, just an idea.