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.
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
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
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
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.