Problem scripting with SetSiblingIndex()

Hi, I’m doing a system where the game calculates 83 different rolls, and returns the DMG that everyone does on a variable. I am trying to order the different rolls by the DMG they do, but I’m having some trouble doing it. Here’s the code:

Your duplicate post got deleted. Please edit your question when you want to add more details and don’t open new questions on the same issue.

Anyways…
This line:

previousDMG = roll.GetComponent<Transform>().GetSiblingIndex();

should probably be this:

previousIndex = roll.GetComponent<Transform>().GetSiblingIndex();

Though I would highly recommend to not use the ordering of the transform components for sorting. Apart from that you essentially doing a single iteration of bubble sort that would not sort all objects and is extremely inefficient.

It would be way better to store your objects in a List<DMGCalculator> and just use the Sort method. This uses quick sort and would be much better for performance reasons. Once your List is sorted you can simply rearrange the transform components according to the list, if that’s even necessary.