Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Workspace.road.Part.Script:2: attempt to index field 'Parent' (a nil value)?

Asked by 5 years ago

while true do script.Parent.Parent.Parent = workspace wait (4)script.Parent.Parent.Parent = serverstorage wait(4) end

1
If any one of those parents is nil, it's going to be trying to index nil. For example, if the second time you index parent were nil, then you would be doing something like nil.Parent, which is not allowed in Lua. User#25115 0 — 5y
0
^ starmaq 1290 — 5y

1 answer

Log in to vote
0
Answered by
starmaq 1290 Moderation Voter
5 years ago

You're probarly parenting it wrongly, recheck. As plegeth said, if a parent is nil it will error, how may a parent be nil you ask? well, nil means if you wanna simplify it, something that doesn't exist. and try to do for example in lua nil.Name will erroe, since you can't. So let's say you got a part inside workspace, and a script inside that part, doing script.Parent.Parent.Parent.Parent will result into an error, since the 1st parent is the part, the 2nd parent is Workspace, the 3rd is game, and 4th doesnt exist, since game doesn't have a parent. So it's nil because it's not a thing.

Ad

Answer this question