Attempt to index nil with 'Name' but it still finds the part?

What’s causing this error?
and the error comes after it prints everything which is what’s confusing me the most

Here’s the code:

feel free to ask me to clarify anything

Would be helpful if you showed us the errornous code.

Looking at your image it seems like you are checking each of the wheels in a vehicle? Seems like one of the wheels aren’t set up right, or its searching in the wrong place, it’s missing “v.Part1.Parent.Parent”

Would need a bit more of the script - namely the area that calls this for loop

1 Like

Here’s more of the code:


and here’s how the parenting structure works:
image
Thanks!

I believe I did? the second image. Look at the numbers on the very end of each line in the console, they represent the lines of code in the script. Thanks :smiley:

Issue looks to be that you are iterating over the welds in your weld list while also adding new welds to that list that aren’t completely set up

so you think I should put them elsewhere, and when I’m done, put them back into the welds folder? lemme give that a try

Edit: doesn’t work, as it no longer knows the variables created inside of the if statement… let me think of a different solution

instead of just
v.Part1.Name == “”
do
v.Part1 and v.Part1.Name ==

In case you have a weld with its part 1 set to nil

like this?

yes, I do actually, that’s the problem I believe
I delete one of the parts, but its weld remains, so one of the welds’ part1 becomes nil. I’m working on a fix now :smiley:

bro thank you so much :smiley:
and all of yall honestly, those were some really quick and helpful replys :muscle:
so your solution basically checks whether it even has a part1, pretty smart
again, thank you so much :smiley:

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.