Attempt to index nil with ":GetChildren()" on script.Parent

Honestly I don’t know how much more straightforward this can be

while wait(.1) do
	for i, v in pairs(script.Parent:GetChildren()) do -- issue lies here
		if v:IsA("ViewportFrame") then
			v.CurrentCamera = workspace.CurrentCamera
		end
	end
end

the parent is NEVER nil nor is the script ever re-parented. Just the model called “New” gets cloned and the screengui named “Planets” gets parented to playergui.


here is where the script is located at:
image

honestly this might be a bug but im still hoping that someone could help me.

It’s a client-sided script, so you need to wait for the assets you reference to load in.
(The parent should load first though so I’m a little confused)

Yea exactly I am confused too, in my opinion it should not return any errors. Also this copying thing is done with another local scripts. Basically the entire game is run by local scripts

Fetch the parent outside of the loop and store it in a variable:

local parent = script.Parent
while task.wait(0.1) do
	for _, v in pairs(parent:GetChildren()) do
		if not v:IsA("ViewportFrame") then continue end
		v.CurrentCamera = workspace.CurrentCamera
	end
end

“men/mens” “women/womens” “teeth/teeths” “people/peoples” “one fish/ one fishs”

Unfortunately it did not work because the parent of this script is being cloned

what type of GUI are you using? If you are using a billboard or surface GUI put them inside of PlayerGui and set the adornee to the model, idk if thatll work but worth a shot

You can read the post and you will see.

Oh sorry, I think that you should use the statements for check if “script.Parent” exits, because I don´t have enough information.

i did that, but the thing is that the script thinks the parent never exists so the function never starts

I fixed the first problem but I’ve ran into the same one this time with “script”! Honestly this is just sickening me roblox needs to fix their code

What doesnt work is this line:

script:Waitforchild()


Roblox I beg you fix your damn code

I think into a solution about disable the script first, and when clone is done, then enable script:

Scripts

shouldnt it be like this? because u are checking if it is a ViewportFrame then making it the camera? idk if the spaces are correct tho lol

for i, v in pairs(script.Parent:GetChildren()) do -- issue lies here
    while wait(.1) do
	    if v:IsA("ViewportFrame") then
            v.CurrentCamera = workspace.CurrentCamera
	    end
    end
end

According to the code here, you aren’t waiting for a child. Plus, what was the fix to the original problem?

Only possible error here is, there wasn’t enough time for even the parent to be initialized.
It’s an odd error but, nothing we can’t deal with effectively.

local Planets = script.Parent.Parent:WaitForChild("Planets")

while wait(0.1) do
    for _, v in pairs(Planets:GetChildren()) do
        if v:IsA("ViewportFrame") then
            v.CurrentCamera = workspace.CurrentCamera
        end
    end
end

I’m sure if you added task.wait(1) on top of the whole script, that would work too.
Tempted to add that to this anyways … considering the error.

I have tried that solution already.