Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 5 years ago

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

01local ENEMY_COUNT = 25
02 
03local ServerStorage = game.ServerStorage
04 
05local function spawnEnemies(count)
06    local spawnpoint = workspace.enemyspawn.Size
07 
08 
09    for i = 1, count do
10 
11        local enemy = ServerStorage.Enemies.Gladiator:Clone()
12        enemy.Parent = workspace.enemyspawn
13 
14        local randomX = math.random(spawnpoint.X)
15        local randomZ = math.random(spawnpoint.Z)
16        enemy:MoveTo(Vector3.new(randomX , 10, randomZ))
17    end
18end
19 wait(5)
20spawnEnemies(ENEMY_COUNT)

1 answer

Log in to vote
0
Answered by 5 years ago
01local ENEMY_COUNT = 25
02local ServerStorage = game:GetService('ServerStorage')
03local SpawnPoint = game:GetService('Workspace'):WaitForChild('enemyspawn')
04local enemies = ServerStorage:WaitForChild('Enemies')
05local gladiator = enemies:WaitForChild('Gladiator')
06 
07local function spawnEnemies(count)
08    for i = 1, count do
09        local EnemyClone = gladiator:Clone()
10        EnemyClone.Parent = SpawnPoint
11 
12        EnemyClone:MoveTo(SpawnPoint.Position) -- Enemy must be a model with a primary part
13    end
14end
15 
16spawnEnemies(ENEMY_COUNT)
0
Let me know if you have any issues. AbusedCocopuff4 105 — 5y
Ad

Answer this question