This code ran is to spawn an npc, make it move from one spot to another, and then disappear. Does anyone have an idea of how I could make multiple npcs spawn at different intervals whilst still having the same walking path?
local function pp()
local randPos = math.random(1,2)
local newModel = model:Clone()
local newModelHumanoid = newModel.Humanoid
newModel.Parent = game.Workspace
if randPos == 1 then
newModel:PivotTo(CFrame.new(Folder1:FindFirstChild('1').CFrame.Position))
for i, v in pairs(Folder1:GetChildren()) do
newModelHumanoid:MoveTo(Folder1:FindFirstChild(i).Position)
newModelHumanoid.MoveToFinished:Wait()
end
else
newModel:PivotTo(CFrame.new(Folder1:FindFirstChild('9').CFrame.Position))
for i, v in pairs(Folder2:GetChildren()) do
newModelHumanoid:MoveTo(Folder2:FindFirstChild(i).Position)
newModelHumanoid.MoveToFinished:Wait()
end
end
newModel:Destroy()
end
while true do
wait(1,10)
pp()
end