Hello everyone, I am here on a very weird issue, and I have no clue why it is happening. I am running :GetChildren() on a folder, and it is returning “{}”. I know this should not be happening as the Folder has 3 Parts in it. Any solutions?
local player = game.Players.LocalPlayer
local cam = game.Workspace.CurrentCamera
local camParts = game.Workspace:WaitForChild("CamParts")
local length = #camParts:GetChildren()
local currentIndex = 1
local function setCam()
cam.CameraType = Enum.CameraType.Scriptable
print(currentIndex)
print(camParts:GetChildren()) -- returns {}
local thing = camParts:GetChildren()[currentIndex]
print(thing) -- nil
cam.CFrame = thing.CFrame -- attempt to index nil with CFrame
end
setCam()
for _, v in pairs(script.Parent:GetChildren()) do
v.MouseButton1Up:Connect(function()
if v.Name == "Left" then
if currentIndex <= 0 then
currentIndex = length
setCam()
else
setCam()
currentIndex -= 1
end
else
if currentIndex >= length then
currentIndex = 1
setCam()
else
setCam()
currentIndex += 1
end
end
end)
end
![image](//devforum-uploads.s3.dualstack.us-east-2.amazonaws.com/uploads/original/5X/6/7/1/c/671c022f7ae958d4718585a749f743a1c7582321.png)
3 Likes
Weird suggestion, are those parts inside of the CamParts folder anchored? If not, anchor them. Otherwise they will fall through the entire map and despawn
2 Likes
Yes, they are anchored. Just checked right now.
2 Likes
Alright stupid question #2, you don’t have another folder called CamParts at all in workspace, or any object at all called “CamParts”
1 Like
I mean, you can see the picture I sent. It’s called CamParts
2 Likes
I don’t think that’s what they meant. Do you have another folder/Instance named CamParts in workspace? Not the actual folder itself.
2 Likes
This is what I meant, yeah. If there is another part called CamParts it might be getting that.
1 Like
This is literally all I have in the workspace.
![image](//devforum-uploads.s3.dualstack.us-east-2.amazonaws.com/uploads/original/5X/5/6/2/5/562543c39c3158d1e728478344724d6b928a3336.png)
1 Like
That is very weird, I assume there is no other script that would be messing with that at all, right?
1 Like
it seems like they arent loaded consider using WaitForChild or load the client by this workaround
if not game:IsLoaded() then
game.Loaded:Wait()
end
1 Like
on line 4, they have a WaitForChild on the folder CamParts, so would this actually make a difference?
nvm re-reading quickly, it could
1 Like
Yes, there are more scripts, but I just disabled all of them and I still have the same issue.
1 Like
Nope, still have the same issue.
1 Like
Can you print GetChildren for another instance in your workplace, does that return {} as well, or does it print the Children?
1 Like
print(game.Workspace.Textures:GetChildren())
Returned
![image](//devforum-uploads.s3.dualstack.us-east-2.amazonaws.com/uploads/original/5X/d/6/f/5/d6f587b7b1f710f14c892fb12f084c0d23cafcc6.png)
Hm, okay. Stupid idea, can you re-create the CamParts folder, drag the 3 parts into the new one and delete the old CamParts Folder, make sure no spaces etc.
It’s a really stupid idea but I’m not sure at this point.
1 Like
Did this, still not working though.
1 Like
Hm. Okay, You could try GetDescendants, does the same thing but idk worth a shot.
Secondly, load into your game if GetDescendants isn’t working, check what the client can see, can it see all 3 of those parts client side inside of the CamParts folder, or are they gone?
1 Like
Tried :GetDecendants(), same issue.
The client can see all of the parts.
1 Like
Hm, alright.
repeat task.wait() until #game.Workspace.CamParts:GetChildren() == 3
Can you try putting this at the very top of your script? Let me know the outcome on it.
2 Likes