Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Why do my npc's not spawn on the part?

Ive been trying to get my npc's to clone onto a part but they wont .please someone tell me im stupid and help me...in that order

local ENEMY_COUNT = 25
 
local ServerStorage = game.ServerStorage
 
local function spawnEnemies(count)
	local spawnpoint = workspace.enemyspawn.Size
 

	for i = 1, count do

		local enemy = ServerStorage.Enemies.Gladiator:Clone()
		enemy.Parent = workspace.enemyspawn
		
		local randomX = math.random(spawnpoint.X) 
		local randomZ = math.random(spawnpoint.Z)
		enemy:MoveTo(Vector3.new(randomX , 10, randomZ))
	end
end
 wait(5)
spawnEnemies(ENEMY_COUNT)

1 answer

✓ Accepted answer
local ENEMY_COUNT = 25
local ServerStorage = game:GetService('ServerStorage')
local SpawnPoint = game:GetService('Workspace'):WaitForChild('enemyspawn')
local enemies = ServerStorage:WaitForChild('Enemies')
local gladiator = enemies:WaitForChild('Gladiator')

local function spawnEnemies(count)
    for i = 1, count do
        local EnemyClone = gladiator:Clone()
        EnemyClone.Parent = SpawnPoint
	
        EnemyClone:MoveTo(SpawnPoint.Position) -- Enemy must be a model with a primary part
    end
end

spawnEnemies(ENEMY_COUNT)

1 comment

0

Let me know if you have any issues.

This discussion is preserved as it was. New answers, comments, and votes are closed.