Part is "Not a Valid Member" when it actually is

I am trying to access a part on a model before I then destroy it later in a server script.
However, the script keeps telling me that this part is NOT a member of the object, when it clearly is.


local placeRangePart = previousTower.PlaceRange

I have tried using FindFirstChild and WaitForChild and these do not work either.

EDIT: Grammar fixes

1 Like

Did you re-adjust the parent in a local script?

2 Likes

Easy but usually frowned upon way to do it is to simply add a task.wait() between getting the reference and destroying it

2 Likes

What do you mean? I am certain the parent of “PlaceRange” is the correct parent, the child is there, but studio say it is not a member.

1 Like

The reference won’t be grabbed at all, since studio is saying that it is not a valid member of the parent.

1 Like

Can you show us the script that has the error?

1 Like

1 Like

So you already tried

previousTower:WaitForChild(“PlaceRange”)

1 Like

Yes, it is just an infinite yield. Not sure what is wrong.

1 Like

I have multiple assumptions. It’s that there’s another script changing the parent or deleting the part, or the part is supposed to be created but it hasn’t. Lastly, maybe the script you’re using is a local script?

1 Like
  1. At the time the error is being thrown, I can manually validate that the part is under the right spot.
  2. This part will ALWAYS be created because this function is an upgrade to the current tower, which always has the “PlaceRange” part.
    3, The script is definitely a server script. It is in ServerScript service. And this specific function is called by: upgradeTowerFunction.OnServerInvoke = tower.Upgrade
1 Like

I think the problem is because of the remote function. You should check if you have all of the right information that was passed from the local script. Also, is this line going to a module?

1 Like

What do you mean is this line going to a module?

1 Like

Oh my bad! I thought it was a module function being called. Anyways, you should go look back at the variable “PreviousTower”. It’s where you’re supposed to get “PlaceRange”, so that should be where the error is?

1 Like

Yes, but “PreviousTower” is correctly set to the object that has “PlaceRange” so I am not exactly sure why it would throw an error.

1 Like

Can you take a picture of the error.

1 Like

There is a picture of the error inside of the original post. Underneath the first photo.

1 Like

uh i just came but is it taking the correct model like are there multiple models called “Noob”

1 Like

No, only one model. Do you think it could be because the part is only for that one specific client, and the code is running on the server?

1 Like

Maybe you’re getting the wrong tower from the local script. I’m not sure what else it could be.

1 Like