generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripting Helpers
Home Search
 

Re: attempt to index field 'Parent' (a nil value)

Previous Thread :: Next Thread 
twitchio is not online. twitchio
Joined: 13 Aug 2010
Total Posts: 49
12 Jan 2013 06:46 PM
I have this script but it keeps telling me "attempt to index field 'Parent' (a nil Value)
Im not sure whats wrong but i pointed out the Parent it is talking about so could someone please help?

--------------------------------------------------
B1 = script.Parent.Parent.Box1
B2 = script.Parent.Parent.Box2
B3 = script.Parent.Parent.Box3
B4 = script.Parent.Parent.Box4
B5 = script.Parent.Parent.Box5
B6 = script.Parent.Parent.Box6
B7 = script.Parent.Parent.Box7
B8 = script.Parent.Parent.Box8
B9 = script.Parent.Parent.Box9
B10 = script.Parent.Parent.Box10
B11 = script.Parent.Parent.Box11
B12 = script.Parent.Parent.Box12

function onTouched(Part)
if Part.Name == "Wing1" or "Wing2" then
Part.Parent:remove() -- Parent is on this line
game.Workspace.Button1.Script.Disabled = false
game.Workspace.Button2.Script.Disabled = false
game.Workspace.Button3.Script.Disabled = false
game.Workspace.Button4.Script.Disabled = false
game.Workspace.Button5.Script.Disabled = false
end
if B1.Transparency == 1 then
B1.Transparency = 0
B1.CanCollide = true
elseif B2.Transparency == 1 then
B2.Transparency = 0
B2.CanCollide = true
elseif B3.Transparency == 1 then
B3.Transparency = 0
B3.CanCollide = true
elseif B4.Transparency == 1 then
B4.Transparency = 0
B4.CanCollide = true
elseif B5.Transparency == 1 then
B5.Transparency = 0
B5.CanCollide = true
elseif B6.Transparency == 1 then
B6.Transparency = 0
B6.CanCollide = true
elseif B7.Transparency == 1 then
B7.Transparency = 0
B7.CanCollide = true
elseif B8.Transparency == 1 then
B8.Transparency = 0
B8.CanCollide = true
elseif B9.Transparency == 1 then
B9.Transparency = 0
B9.CanCollide = true
elseif B10.Transparency == 1 then
B10.Transparency = 0
B10.CanCollide = true
elseif B11.Transparency == 1 then
B11.Transparency = 0
B11.CanCollide = true
elseif B12.Transparency == 1 then
B12.Transparency = 0
B12.CanCollide = true
end
end

if B12.Transparency == 0 then
script.Parent.Parent.NewTruck.Disabled = false
end

script.Parent.Touched:connect(onTouched)
Report Abuse
ServerLabs is not online. ServerLabs
Joined: 29 Dec 2010
Total Posts: 2263
12 Jan 2013 06:59 PM
What line is it erroring on?

Report Abuse
twitchio is not online. twitchio
Joined: 13 Aug 2010
Total Posts: 49
12 Jan 2013 07:04 PM
Its at line 16
I put thiis at the end of it --Parent is on this line
Report Abuse
ServerLabs is not online. ServerLabs
Joined: 29 Dec 2010
Total Posts: 2263
12 Jan 2013 07:11 PM
B1 = script.Parent.Parent.Box1
B2 = script.Parent.Parent.Box2
B3 = script.Parent.Parent.Box3
B4 = script.Parent.Parent.Box4
B5 = script.Parent.Parent.Box5
B6 = script.Parent.Parent.Box6
B7 = script.Parent.Parent.Box7
B8 = script.Parent.Parent.Box8
B9 = script.Parent.Parent.Box9
B10 = script.Parent.Parent.Box10
B11 = script.Parent.Parent.Box11
B12 = script.Parent.Parent.Box12

function onTouched(Part)
if Part.Name == "Wing1" or "Wing2" then
print(Part.Parent.Name)
game.Workspace.Button1.Script.Disabled = false
game.Workspace.Button2.Script.Disabled = false
game.Workspace.Button3.Script.Disabled = false
game.Workspace.Button4.Script.Disabled = false
game.Workspace.Button5.Script.Disabled = false
end
if B1.Transparency == 1 then
B1.Transparency = 0
B1.CanCollide = true
elseif B2.Transparency == 1 then
B2.Transparency = 0
B2.CanCollide = true
elseif B3.Transparency == 1 then
B3.Transparency = 0
B3.CanCollide = true
elseif B4.Transparency == 1 then
B4.Transparency = 0
B4.CanCollide = true
elseif B5.Transparency == 1 then
B5.Transparency = 0
B5.CanCollide = true
elseif B6.Transparency == 1 then
B6.Transparency = 0
B6.CanCollide = true
elseif B7.Transparency == 1 then
B7.Transparency = 0
B7.CanCollide = true
elseif B8.Transparency == 1 then
B8.Transparency = 0
B8.CanCollide = true
elseif B9.Transparency == 1 then
B9.Transparency = 0
B9.CanCollide = true
elseif B10.Transparency == 1 then
B10.Transparency = 0
B10.CanCollide = true
elseif B11.Transparency == 1 then
B11.Transparency = 0
B11.CanCollide = true
elseif B12.Transparency == 1 then
B12.Transparency = 0
B12.CanCollide = true
end
end

if B12.Transparency == 0 then
script.Parent.Parent.NewTruck.Disabled = false
end

script.Parent.Touched:connect(onTouched)

_________________________________________________________

See if this will work, it should print the parents name, if it doesn't then it's a hierarchy error.
Report Abuse
twitchio is not online. twitchio
Joined: 13 Aug 2010
Total Posts: 49
12 Jan 2013 07:17 PM
Yes, it printed the name of the Parent and i didnt get the error
But i added the Part.Parent:remove() back in and it print the name of the Parent but i got the error again
Report Abuse
ServerLabs is not online. ServerLabs
Joined: 29 Dec 2010
Total Posts: 2263
12 Jan 2013 07:18 PM
Hm.. Try Part.Parent.Parent = nil
Report Abuse
Sharpshooter26 is not online. Sharpshooter26
Joined: 26 May 2010
Total Posts: 5166
12 Jan 2013 07:21 PM
remove() was deleted


Use Destroy() or ClearAllChildren()
Report Abuse
twitchio is not online. twitchio
Joined: 13 Aug 2010
Total Posts: 49
12 Jan 2013 07:37 PM
Hmm... None of those seem to work
Report Abuse
twitchio is not online. twitchio
Joined: 13 Aug 2010
Total Posts: 49
12 Jan 2013 09:23 PM
bump
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripting Helpers
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image