for some reason I’m getting the error “attempt to index nil with parent” on line 9 even though line 9 worked (the black hole was put in the workspace.)
Code:
Error:
Proof the object exists:
for some reason I’m getting the error “attempt to index nil with parent” on line 9 even though line 9 worked (the black hole was put in the workspace.)
Code:
Error:
Proof the object exists:
What are you trying to do here? Set the BlackHole’s parent to ServerStorage? Why do you need to do that?
I’m trying to put the black hole in the workspace as seen in line 9. (ignore line 22)
line 9:
game.ServerStorage.EventModels:FindFirstChild("BlackHoleItem").Parent = workspace
Wait what, then why is the name different this time from BlackHole to BlackHoleItem
I said ignore line 22. I accidentally wrote line 22 wrong. But line 9 is the one erroring.
How would I know which line… Just copy and paste which is the code that’s giving an error.
this is the code.
30 lettersss
Sorry I’m dumb, have you tried WaitForChild()
?
What kind of script is this, keep in mind local scripts don’t have access to ServerStorage!
You are attempting to find the property called Parent
which doesn’t exist since FindFirstChild
returns nil if it doesn’t find it. Have you checked if BlackholeItem
actually exists in ServerStorage
?
its a normal script, not a local script.
Strange. Have you tried printing the object in the output see if it works?
print(game.ServerStorage.EventModels:FindFirstChild("BlackHoleItem"))
it prints fine.
of course its gonna print the item its on run, you need to use WaitForChild(“BlackHoleItem”) because the object still does not exist, its loading.
Edit: If it still gives an error something like attempt to index nil with WaitForChild; the parent is still loading.
I see the problem, it is a while loop so when you parent it to workspace in the first loop, it is no longer in server storage. Then in the second loop, it cannot find BlackHoleItem, thus errors.
Instead of this:
game.ServerStorage.EventModels:FindFirstChild("BlackHoleItem").Parent = workspace
Can’t you just do this for line 9, Isn’t that the same thing?
game.ServerStorage.EventModels = workspace
That would bring all the models that are stored inside that folder so no, it is not the same thing.
However EventModels Children BlackHoleItem’s Parent is Event Models
Correct, and what the code does is change its parent to workspace.