I have this script local index = 0
while true do
index +=1
game.Lighting.TimeOfDay = index
if index == 12 then
– Spawn the aliens
elseif index == 24 then
– Unspawn the aliens
end
wait(60)
end
What script would I use for the spawning and despawning the aliens?
Yes A CPU that would follow you around, hurt, and kill the player. I have the alien, i just dont know how to spawn and despawn them by a script like this
To enter your code you might want to use this(`) sign which is located above the tab button and to the left of the number1 three times
local index = 0
while true do
index = index + 1
game.Lighting.TimeOfDay = index
If index == 12 then
-- Spawn
elseif index == 24 then
index = 0
--Aliens:Destroy()
end
wait(60)
end
use this character(```) while you write your code so it looks significant and after you are done writing your code use it again and then the font will turn back to normal
local Alien = game.ServerStorage.Alien
local AlienAmount = 10
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
Anyways, You could save the NPC model in ServerStorage, and clone it out into workspace, and let them do their work, when done, just remove all of the clones.
Yes, but no, easier to clone from, just have to deal with exploiters, with Serverstorage exploiters cant spawn more, replicated they can, really depends on skill