Script Fails To Index "Parent", When Parent Obviously Exists

Below is a function from a script in a game I’ve been working on:

I have looked through it many times, and I have not been able to identify the issue. The error log constantly reports an error at line 310 in this script throughout the game (It’s a major script in an NPC that is cloned a lot), claiming that it can not find a field called “Parent”. The script is in a Humanoid inside an NPC character.

How can script.Parent.Parent be invalid, if the script is always inside the humanoid in the character? This hasn’t been too much of an issue, but it is annoying and I would like help fixing it.

As it’s line 310, do you change the script’s parent in the script?

1 Like

I made no change to the location of the script. The script error was identified as originating from a script in the location it should be in. Thanks for asking, though.

Might seem odd but why not try taking away one parent then print(x) and see what comes out? then add a parent back then print(x) to see what it prints?

Or if you really need to, try doing a WaitForChild(), but only if really needed

That’s a good idea! I will try the printout and see what I get.

Alright, I have determined that the script is somehow not parented to anything. I don’t know why this is. I tried printing the name using GetFullName and it just said “Script”, and not workspace.Waiter.Humanoid.Script or anything.

Did you even use “x”? [30 char]

1 Like

Actually, that’s a really good point, I never ended up using it. Heh. That’s weird. Thanks mate!

1 Like