Using a table to organize how many frame templates are created

Hello!

I’m currently working on a plugin and this portion of the scripting needs the user to type a number (ex: 6) and it’ll generate the template I have set up 6 times with a number on the top right for each indicating which frame it is (to prevent confusion).

I’m unsure how to do this in a way for it to be compatible with Script.Source later on

Dialog Main Frame:
https://gyazo.com/0d7a8d4c5f474a4f603f99824ee3567d
https://gyazo.com/8dd244440019da4ee56039a93353e547

Template Frame:
https://gyazo.com/59115a513652ad75d38e601b6f91c9ba
https://gyazo.com/38087be6fcf74eccbad9ab4c6964757c

I tried using tables but I couldn’t quite seem to fit it with how this plugin is intended to be built.

If there is an easier method or if tables are indeed possible please do let me know, thank you

I’m pretty confused about what you’re asking, could you elaborate a bit more?

I’m essentially looking for a method where when they type a number here and submit it:
https://gyazo.com/8dd244440019da4ee56039a93353e547
It’ll create 6 of these frames, number each 1-6 (assuming you typed 6 in there)
https://gyazo.com/38087be6fcf74eccbad9ab4c6964757c
and store it in a folder for organization
(each template will be named Page# according to it’s number)
and the left and right buttons in the screenshot above should be able to cycle through all of them

Use a for loop to create the pages.

You can name them based on the loop variable:

-- your plugin script
for page = 1, selectedNumber do 
	local clone = PageTemplate:Clone()
	clone.Name = "Page" .. tostring(page)
	clone.Parent = -- ... wherever
end

Obviously there are variables you need to fill out still.

You could then extract the page number from the name in a LocalScript inside the PageTemplate. After that you can just add/subtract 1 to get the previous and next page:

-- LocalScript in the PageTemplate
-- get page no. from name
local page = tonumber(script.Parent.Name:sub(5))

local nextPage = script.Parent.Parent:FindFirstChild("Page" .. tostring(page+1))

local prevPage = script.Parent.Parent:FindFirstChild("Page" .. tostring(page-1))