Spawn Script Not Working as expected

local amn = 80
local curamn = 0
local items = game.ServerStorage:WaitForChild("Shells"):GetChildren()

while wait(.01) do
	if curamn == amn then
		curamn = curamn + 1

		local randomItem = items[math.random(1, #items)]
		randomItem.Name = "Shell"
		randomItem.CanCollide = true
		randomItem.Position =,-179.25),0,math.random(24.25,1121.75))
		randomItem.Parent = workspace

Whenever the script creates 2 new shells, they get deleted, in the end of the loop leaving me with only 2 shells spawning.

So basically my shells are getting automatically deleted. This is not a script in my game as everything was scripted by me.

why are you removing this script?

the shells are spawning. when it reaches max amount it deleted. i gtg but if you can help me tho yo can

The script is taking the item from ServerStorage and then moving it to the workspace. I suspect what you intend for it to do is to clone the item from ServeStorage then moe to the workspace.

-- Change this line:
local randomItem = items[math.random(1, #items)]
-- to this:
local randomItem = items[math.random(1, #items)]:Clone() -- makes a new copy of the item

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.