For loop not creating all parts

im making like a WPM calculator game like type racer. i ran into a problem. i’m trying to clone parts for each character in a word. one of my scripts selects multiple words at random from a table and sends it to the server. (selectedwords is the table that is full of randomly selected words)

in my output, it says that there are 229 characters in the table; therefore it should create 229 parts. the for loop says that it created 229 parts but when i open my folder, there are only 110 parts inside. (for some reason it caps at 110). ty guys!

character count output:
image

for loop count output:
image

parts in the folder (says 110):
image

code:

letterEvent.OnServerEvent:Connect(function(p, selectedWords)
	--if existing letters, fillblocks exits

	for _, letter in pairs(letters:GetChildren()) do
		SIZEOFFSET = 0
		letter:Destroy()
	end

	for _, fillblock in pairs(FillBlockFolder:GetChildren()) do
		fillblock:Destroy()
	end
	
	-----------------------------------------------------------------------
	
	transfer = selectedWords

	local randomColor = getRandomColorFromAttribute(config)
	local currentWord = config:GetAttribute("currentWord")
	config:SetAttribute("currentWord", selectedWords[1])
	
	for _, randomWord in ipairs(selectedWords) do
		local randomWordLength = #randomWord
		totalCharacters += randomWordLength
		
		for l = 1, randomWordLength do
			LETTER_INDEX += 1
			local currentLetter = string.sub(randomWord, l, l)
			local letterClone = invisibleLetter:Clone()
			letterClone.Name = LETTER_INDEX
			local textlabel = letterClone.SurfaceGui.TextLabel
			textlabel.Text = currentLetter
			letterClone.Color = randomColor
			letterClone.Parent = letters
			letterClone.CFrame = letterClone.CFrame * CFrame.Angles(0, math.rad(180), 0)
			local GapbetweenLetters = Vector3.new(SIZEOFFSET * 1.25,0,0)
			letterClone.Position = letterSpawnLocation.Position - GapbetweenLetters
			SIZEOFFSET += letterClone.Size.X
			
			if letterClone then
				print("cloned letter part: ", currentLetter, LETTER_INDEX)
			else
				warn("failed to clone: ".. currentLetter, LETTER_INDEX)
			end
		end
		task.wait(.1)
	end
	
	
	local a = 0
	for i, word in ipairs(selectedWords) do
		a += #word
	end
	
	print(selectedWords)
	print("total Characters calculated: "..totalCharacters, "total Characters in table: "..a)
	
	config:SetAttribute("currentCharacters", totalCharacters)
	SIZEOFFSET = 0
	focusCamera:FireClient(p, "focusStartBlock", CURRENT_INDEX, SIZEOFFSET)
end)

and here’s a visual representation:

1 Like

Just to check - have you got streaming enabled turned on?
If so, does switching it off have any impact?

1 Like

Have you verified that Archivable is turned on for each part?

1 Like

It’s most likely from the new Roblox feature StreamingEnabled that doesn’t render objects which might be too far away.

1 Like

yes it did. works perfectly now. tysm man!!

you were absolutely right! never in a hundred years would i have solved that. tysm for ur help Mat!!

1 Like

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