Can I navigate something I don't know the name of but I know that it's the only parent of a folder

Hi,
The title says all, I have a folder which contains nothing when game starts running but when player want to play an obby a script moves obby to this folder (from ReplicatedStorage) but when player want to reset or finish the obby it need to move the obby to ReplicatedStorage again but I’m doing it in other script which don’t know which obby is it, so is there a way to get this obby without :GetChildren() function?

Sorry for bad grammar but I’m in a hurry

2 Likes

An easy way to do this is have a StringValue in the Obby with the value set to the obby name, when you move it to the workspace you can rename the obby to “Map” and when you move it back look for the model named “Map” in the workspace, move it to ReplicatedStorage and set the name to the value you had before it was called map (in the string value)

An even easier way
Clone the obby into the workspace and name it “Map”. In the other script just destroy that model.

1 Like

Both ways will not fit with the game system, I wanted to get something like workspace.LoadedObby:GetOnlyChildren()
OnlyOneChildren

1 Like

If you use either method you can do game.Workspace.LoadedObby.Map

Or alternatively you could do: game.Workspace.LoadedObby:GetChildren()[1]

1 Like

easy

Folder.ChildAdded:Connect(function(child)
    --child is the instances that has been paranted to the folder
end)
1 Like

i’m not to sure why you are not allowed to use GetChildren but here is how to do it

-- Script 1

-- get all obbys in the Obbys folder
local obbys = game.ReplicatedStorage.Obbys:GetChildren()

-- select a random obby
local obby = obbys[math.random(#obbys)]

-- move the selected obby to the LoadedObby folder
obby.Parent = workspace.LoadedObby

-- Script 2

-- wait 30 seconds 
task.wait(30)

-- move the obby back to the Obbys folder
for i child in ipairs(workspace.LoadedObby:GetChildren()) do
    child.Parent = game.ReplicatedStorage.Obbys
end
1 Like

I decided to do it like that

workspace.LoadedObby:GetChildren()[1].Parent = ReplicatedStorage.Obbies

Thanks for the help