[SOLVED] How to print something in order at the end of the name have a number in order

Do anyone know how to make a printing that prints an object or frame name and at the end of the name have a number, and base on the number the print will print it on order,
All that in a
for i, v in pairs(stuff:getchildren()) do?

1 Like

Can you reword your issue?

This part is really confusing. But for the first part where you just want to append a number to the name of what’s printed, there’s multiple ways:

  1. String concatenation
for i, v in stuff:GetChildren() do print(v.Name..i) end
  1. String interpolation
for i, v in stuff:GetChildren() do print(`{v.Name}{i}`) end
  1. Print concatenation
for i, v in stuff:GetChildren() do print(v.Name, i) end
  1. String.format
for i, v in stuff:GetChildren() do print(string.format("%s%s", v.Name, i)) end

If you care about performance, only use string concatenation since that’s the fastest in Luau. If you care about readability and beauty, use string interpolation :upside_down_face:

If you are looking for an ordered list, here is a GitHub link with what you may be looking for:

Ordered table for Lua.

Updated i solved the problem, by myself, and some help on a discord server for roblox studio devs

so what i wanted achive is this:

	task.spawn(function()
		for index = 1, #bar.Base:GetChildren() do --this are guis, are 5 frames that is looking on
			print(index) --prints the amout of things
		end
	end)

and then make a limit that is this:

	task.spawn(function()
		for index = 1, #bar.Base:GetChildren() do
			if index > 5 then return end -- the limit
			print(index)
		end
	end)

and then the finally the real thing script that i make:

	task.spawn(function()
		for index = 1, #bar.Base:GetChildren() do
			if index > specslots then return end
			local child = bar.Base["Base_" .. index] --in the gui, finds any thing with the first words "Base_" and then a number
			--print(child)
			child.number.Visible = true-- make "child" visible
			child.warning.Visible = true-- this is a cooldown frame thing not really important
		end
	end)

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