#ServerScriptService.Pets76 attempt to index nil with 'Position'
10 messages · Page 1 of 1 (latest)
Based on your description and looking just a little at your code I guess when you try to equip number 7, the local petPosition is going to be set to the 7th value in the PetPositions table, which doesn't exist. When a table entry doesn't exist the value will be nil which is basically nothing, and then on the next line you are trying to get the Position value of this, and you will get an error when trying to look up a value on nil. To fix this you should probably just check earlier to make sure you don't try to equip another when you already have 6.
and why I'm 7 when after 6 it bugs
Ok, so you're saying the exact problem happens even if you have 7 entries in the table, and that it happens when you are adding number 6, and not when you are adding number 7 (which I guess shouldn't be possible anyway). If that's the case, can you show the GetPetOrder function? Also, it would be very useful if you can verify whether I guessed the line for the error right?
It seems that if you have a pet in slots 1, 2, 3, 4, and 5 then nothing will be returned from this function. Then in the first code posted you use this (non-)value as an index into PetPositions, and since the index does not exist the petPosition local variable will be nil. When you try to get the Position from this nil-value you get the error.
I suspect the key to fixing your problem is to make sure GetPetOrder works also when you have slots 1-5 all taken.
i found the fix thx for you help
do you have an idea of how to make that when I walk the pet shave an animation