Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Attempt to index parent nill? I need help with my script.

So I got an error when I changed because a user told me to I did but it still says!

Error:


11:32:40.514 - kit = script.Parent.Parent.Parent.Seat.Value.Parent.Parent
11:32:40.520 -  (x2)
11:32:40.522 - function onClicked()
11:32:40.523 - --starting up engine one--
11:32:40.525 - script.Parent.On.Visible = false
11:32:40.526 - script.Parent.On.Active = false
11:32:40.528 - script.Parent.Off.Visible = false
11:32:40.529 - script.Parent.Off.Active = false
11:32:40.531 - script.Parent.:1: attempt to index nil with 'Parent'

Code:


kit = script.Parent.Parent.Parent.Seat.Value.Parent.Parent


function onClicked()
--starting up engine one--
script.Parent.On.Visible = false
script.Parent.On.Active = false
script.Parent.Off.Visible = false
script.Parent.Off.Active = false
script.Parent.Animations.Value.ONE:WaitForChild('Motor').MaxVelocity = script.Parent.Animations.Value.ONE:WaitForChild('Motor').MaxVelocity + 0.0025
wait(1)

I suspect it may be in there if you need the full code dm me on discord AviaFlyHigh#7056

1 comment

0

That means that the script has no parent, or one of the parents can't be found, it's confusing since the first line has literally five parents.

1 answer

✓ Accepted answer

I would suggest rather than using so many .Parents to set the kit variable, reference whatever kit is relative to where it is in the DataModel (Workspace, ServerStorage, etc.) For instance, if kit is in the workspace you could do something like:

kit = workspace. --- ... path to kit

The error is saying "attempt to index nil with Parent" because somewhere when defining kit, you try to index the Parent of an object that does not exist (or nil.)

This discussion is preserved as it was. New answers, comments, and votes are closed.