Assure Model Descendant Order for RelativeIDs

I am trying to create a model that has a server and client copy. I need the server and client to communicate.

Server Part X → ToID(ServerPartX) → Universal ID → ToPart(UniversalID) → Client Equivalent.

In Game this works, in Studio it errors, because the Client and Server clone of the model in ReplicatedStorage get different orders for absolutely no reason.

for index, descendant in pairs(model:GetDescendants()) do

	if descendant:IsA("BasePart") then 
		associationArray[index] = descendant
		associationArray[descendant] = index
	end

end

function IronRIS:getAssociation(partOrId) 
	return associationArray[partOrId]
end 

Here is the source code

Maybe try ipairs ?

If not, although tedious, could you add an identifier for each instance in your model? You could easily do this by using the command bar, but you could like add an IntValue in each part that increments +1 each time, so it acts as an ID. This wouldn’t be done at runtime so it’d remain constant.