Npc spawn count

while true do
wait(0)
local Clone = game.ServerStorage.ClonePart

script.Parent.Touched:Connect(function()
	Clone.Parent = game.Workspace
	Clone.Anchored = false
	wait(0) 
end)

end

local debounce = false

script.Parent.Touched:Connect(function()
if not debounce then return end
debounce = true
for i = 1, 3 do
local Clone = game.ServerStorage.ClonePart:Clone(3)
Clone.Parent = workspace
Clone.Anchored = false
task.wait()
end
task.wait(5) – change this to increase/decrease cooldown time
debounce = false
end)

so i want to spawn 3 npcs but it only spawns one can anyone help me?

You didn’t write your loops correctly. It would be “for i = 1,3,1 do” Intro to For Loops | Roblox Creator Documentation

ok i did now how do i change the spawn count

local debounce = false

script.Parent.Touched:Connect(function()
	if not debounce then return end
	debounce = true
	for i = 1, 3, 1 do
		local Clone = game.ServerStorage.ClonePart:Clone()
		Clone.Parent = workspace
		Clone.Anchored = false
		task.wait()
	end
	task.wait(5)
	debounce = false
end)

It didnt work for some odd reason

are there any errors popping up?

The increment number is actually optional. By default, it’s one.


It looks like you have a memory leak in your code. You should try removing the while loop.