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

I keep getting attempt to index nil with 'Parent'? Can somebody help me?

So I keep getting error like this!


10:28:21.632 - kit = script.Parent.Parent.Parent.Seat.Value.Parent.Parent
10:28:21.634 - system1 = kit.ONE
10:28:21.637 - system2 = kit.TWO
10:28:21.639 - ONE =  script.Parent.Animation.Value.ONE:WaitForChild('Motor')
10:28:21.641 - function onClicked()
10:28:21.643 - system1.A.ON:Play()
10:28:21.646 - system2.A.ON:Play()
10:28:21.648 - 
10:28:21.651 - ONE.MaxVelocity = ONE.MaxVelocity +:1: attempt to index nil with 'Parent'

And here is the full code!

kit = script.Parent.Parent.Parent.Seat.Value.Parent.Parent
system1 = kit.ONE
system2 = kit.TWO
ONE =  script.Parent.Animation.Value.ONE:WaitForChild('Motor')
function onClicked()
system1.A.ON:Play()
system2.A.ON:Play()

ONE.MaxVelocity = ONE.MaxVelocity + 0.0025
wait(1)                                        
ONE.MaxVelocity = ONE.MaxVelocity + 0.0025
wait(1)
ONE.MaxVelocity = ONE.MaxVelocity + 0.0025
wait(1)
ONE.MaxVelocity = ONE.MaxVelocity + 0.0025
wait(1)	

ONE.MaxVelocity = ONE.MaxVelocity + 0.0025
wait(1)
ONE.MaxVelocity = ONE.MaxVelocity + 0.0025     
wait(1)
ONE.MaxVelocity = ONE.MaxVelocity + 0.0025
wait(1)
ONE.MaxVelocity = ONE.MaxVelocity + 0.0025
wait(1)
	
ONE.MaxVelocity = ONE.MaxVelocity + 0.0025
wait(1)
ONE.MaxVelocity = ONE.MaxVelocity + 0.0025      
wait(1)
ONE.MaxVelocity = ONE.MaxVelocity + 0.0025
wait(1)
ONE.MaxVelocity = ONE.MaxVelocity + 0.0025
wait(1)
	
ONE.MaxVelocity = ONE.MaxVelocity + 0.0025
wait(1)
ONE.MaxVelocity = ONE.MaxVelocity + 0.0025      
wait(1)
ONE.MaxVelocity = ONE.MaxVelocity + 0.0025
wait(1)
ONE.MaxVelocity = ONE.MaxVelocity + 0.0025
wait(1)
	
ONE.MaxVelocity = ONE.MaxVelocity + 0.0025
wait(1)
ONE.MaxVelocity = ONE.MaxVelocity + 0.0025      
wait(1)
ONE.MaxVelocity = ONE.MaxVelocity + 0.0025
wait(1)
ONE.MaxVelocity = ONE.MaxVelocity + 0.0025
wait(1)
	
ONE.MaxVelocity = ONE.MaxVelocity + 0.0025
wait(1)
ONE.MaxVelocity = ONE.MaxVelocity + 0.0025      
wait(1)
ONE.MaxVelocity = ONE.MaxVelocity + 0.0025
wait(1)
ONE.MaxVelocity = ONE.MaxVelocity + 0.0025
wait(1)
	
script.Parent.Confirm.BackgroundColor3 = Color3.new(0, 255, 0)
end

function onClicked2()
system1.A.OFF:Play()
system2.A.OFF:Play()
script.Parent.Confirm.BackgroundColor3 = Color3.new(255, 0, 0)
end

script.Parent.On.MouseButton1Down:connect(onClicked)
script.Parent.Off.MouseButton1Down:connect(onClicked2)

Can somebody please help also this is for a motor animation.

1 answer

✓ Accepted answer

Parent is nil, it means it does not exist, try to check it's location if you defined it right OR use :WaitForChild() in case your script executes faster than the instance loads. Try printing out kit and check if it prints nil. Hope it helps.

Also this is tip, instead of using dozens of same lines, you can use simple for loop, more here: for loop

-kirda, discord: kirda#1705

3 comments

0

And where do I post that thing at? Please answer

0

You mean print? You post it after defining kit, so at line 2 i guess. If it prints nil then something is wrong.

0

I added you on discord AviaFlyHigh#7056 hope you can get in contact.

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