Alien spawn script

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?

Can you specify what you mean by aliens? Are you talking about a NPC? Could you provide more info about what you are trying to do?

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

1 Like

What script would I need to spawn the aliens tho

1 Like
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
2 Likes

first of all WOW, Im guessing I would have to put an alien into ServerStorage. and where would this script go?

The script would go into server script service

2 Likes

NPC?
A CPU is your computers processor, an NPC is a computer controller character
CPU = Central Processing Unit
NPC = Non-Player Character

1 Like

Yes An NPC that follows and kills the player. I have that already tho

1 Like

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.

Wouldn’t the Replicated Storage be better for the Clone Reference of the NPC’s

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

1 Like

It would not matter if they spawned more on their own client, you can put them in ReplicatedStorage with no problems and no worries about exploiters

Thanks for pointing that out, lol. I meant to say NPC as you inferred. I should probably get more sleep.