Unsure if this is it, but try converting this for loop into an in pairs loop and see if it fixes it. There’s nothing wrong with the current script but maybe changing the type of loop can fix it, or at least give you more insight into the problem.
It’s a bit difficult to visualize what’s going on just from the code you provided, but it might be that you’re mistaking the ‘ScrollingFrame.temp’ object for the new Clone of it.
For every iteration in the loop, it seems like you parent the new ViewportFrame to the original temporary object:
I think that’s the original object you’re cloning: ‘ScrollingFrame.temp’. What you can do is delete it after you’re done making your clones and you can compensate by just creating one more clone beforehand. Glad it works!