Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

trying to set string names from a table but, ends up setting it all to one name, help??

local data = {"noob", "string", "NeilTheGreat"}
for _, v in pairs(data) do        ------------------- this entire section needs help.
			print(v)
			local stringName = v
			for _, ayo in pairs(workspace.Folder:GetChildren()) do
				ayo.Name = stringName
			end
		end

What I am basically trying to do here is, there is a folder with plain string values, in fact 3 string values. When I try to change their name to the items in data, it ends up changing it to NeilTheGreat each time for all of the values. And since I want it random, [1], [2], [3] won't work. Any help would be gr8! thanks

1 answer

✓ Accepted answer

Give this a try, not sure if it will work:

local data = {"noob", "string", "NeilTheGreat"}
for i, v in pairs(data) do 
	print(v)
	local stringName = v
	for ii, ayo in pairs(workspace.Folder:GetChildren()) do
		if i == ii then
			local num = i
			ayo.Name = data[num]
		end
	end
end

2 comments

0

Ok I will test it in a while just not right now, i will accept if it works otherwise I will ask you if there is an error or not. Thanks for the nested loop help.

0

Thank you so much!

This discussion is preserved as it was. New answers, comments, and votes are closed.