Is it possible to change the index of an instance?

Hello. I’ve encountered a simple issue: I would like to change the index order of an instance inside a folder.
In our example, here is our folder:
image
However, if we run this command:
image
Our input will be this:
image

I would need to change the index since it shows these choices in a ‘random’ order (Choice 3 → Choice1 → Choice 3)
(Read the code, you will understand what I mean:)

for i = 1,#ChoicesFolder  do
	TS:Create(ChoicesFolder[i],TweenInfo.new(.5),{TextTransparency = 0}):Play()
	wait(.3)
end

I appreciate the support. Love <3

1 Like

Why not do ChoicesFolder["Choice"..tostring(i)]?

3 Likes
local ChoicesFolder = workspace.ChoicesFolder
local TS = game:GetService("TweenService")


local choices = ChoicesFolder:GetChildren()


for i = #choices, 2, -1 do
    local j = math.random(i)
    choices[i], choices[j] = choices[j], choices[i]
end

for i = 1, #choices do
	TS:Create(choices[i], TweenInfo.new(.5), {TextTransparency = 0}):Play()
	wait(.3)
end
1 Like

Also works, but the other solution is easier, should’ve also thought about this one too, thank you :heart:

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