Item spawning at random locations

Basically what I have is when you collect an item, it waits 2 seconds, before respawning said item again. However, atm, it’s being firedtwice, thus creating 2 items, instead of just the one. I tried adding a debounce but that didnt work

local function createNewItem(item, pos, spawnSpot)
	spawn(function()
		wait(2)
		
		for _, v in pairs(Items:GetDescendants()) do
			if v:IsA('BasePart') or v:IsA('MeshPart') then
				local NewItem = v:Clone()	
				NewItem.Parent = ItemsHolder
				print('Item found', NewItem.Parent)
				break
			end
		end
	end)
end

local Spawn
	for _, v in pairs(ItemSpawns:GetDescendants()) do
		if v:IsA('BasePart') then
			if v.Position == item.Position then
				Spawn = v.Position
			end
		end
	end
	
	if not ItemDebounce then
		ItemDebounce = true
		createNewItem(item.Name, item.Position, Spawn)
		wait(0.01)
		ItemDebounce = false
	end
	
	item:Destroy()
2 Likes

Did “Item found” Print twice at the top?