Im not sure whats causing the problem, both the mesh and surface exist. i get this

its when i run this particular function

its when i run this particular function
Function offsetUV#(entity,surf,offx#,offy#) If entity=0 Then Return 0 If surf = 0 Then Return 0 For j=0 To bbCountVertices(surf)-1 u#=Float(bbVertexU(surf,j)) v#=Float(bbVertexV(surf,j)) bbVertexTexCoords surf,j,u#+offx#,v#+offy# Next bbUpdateNormals entity End Function