Attempt to index nil with GetChildren

What do you want to achieve?
You know the “creator” thing to know who it who that killed the person in Classic Sword,I’m putting it on my sword but I’m having an error with a function related to the above…

What is the issue?
The problem is that it tells me “attempt to index nil with ‘GetChildren’”

in this line of code:

function UntagHumanoid (humanoid)
for i, v in pairs (humanoid: GetChildren ()) do --Error Line!
if v: IsA ("ObjectValue") and v.Name == "creator" then
v: Destroy ()

What solutions have you tried so far?
I don’t know what to do to really fix it and I have had a lot of experience with bus and errors. :sweat_smile:

Please help me fix this error!

Btw I have seen quite a lot of related topics about this and none helped me that’s why I’m doing I’m

Hello. How are you calling the function?

It returns nil because Humanoid is not defined in your script.
Can you show us how you called the function?

UntagHumanoid() Thats how I am calling the function.

UntagHumanoid() Thats how I am calling the function in my script.

Yea, you will have to pass an argument, as the defined function has and uses a parameter.

Something like this can be done if it is a local script: UntagHumanoid(game.Players.LoaclPlayer.Character.Humanoid)

UntagHumanoid(humanoid) You mean that right?

1 Like

You’re passing nothing to the function, so it will return nil.
If Humanoid is defined where you’re calling the function from, try UntagHumanoid(Humanoid).

Expected identifier when parsing expression, got ‘)’

If that doesn’t work, can you post the full script?

Which line causes this error? These happen due to small syntactic errors, and are hard to explain without context.

It expects an end usually.

function UntagHumanoid(humanoid)
for i, v in pairs(humanoid:GetChildren()) do --this line causes the error And I tried doing calling The Humanoid
if v:IsA(“ObjectValue”) and v.Name == “creator” then

Can you show us the full script? That way we can understand what type of script you’re using and also help you better.

I cant due to the Max of letters is 5000 How I can do it?

No, we meant the place where you’re calling the function from.

1 Like

Try pasting the script into a text file and upload it.

1 Like

message.txt (66.4 KB)

1 Like

The Line I call the function is 919 and 920

1 Like

Try replacing the UntagHumanoid(humanoid) with UntagHumanoid(TargetHum) if you’re trying to remove the creator value from the target.


Thank you and Now that I should replace with TagHumanoid?