Have you created the type instance yet, before calling the function, which returns the model's handle?
The problem can be that the function DOES return the correct handle for your new mesh, but cannot store it into the array, because the type-instance doesn't exist yet for that specific array-index (= n).
dim actors.TOK_actor(NumberOfActors) ; Create as many type-instances as there are indexes in the array and store the pointer to each instance in the array for i = 0 to NumberOfActors actors(i) = new TOK_actor next actors(n) = create_geometry_actor(actor.TOK_actor)
The problem can be that the function DOES return the correct handle for your new mesh, but cannot store it into the array, because the type-instance doesn't exist yet for that specific array-index (= n).