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 4 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

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

Log in to vote
0
Answered by 4 years ago
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)
0
Let me know if you have any issues. AbusedCocopuff4 105 — 4y
Ad

Answer this question