So I’m attempting to make a local for a folder no matter where it is in the game. Here’s the script so far:
local MWFolder = game:GetDescendants("MainWorld")
if MWFolder.Parent == game.Workspace then
print("MWFolder Found; Workspace")
end
if MWFolder.Parent == game.ReplicatedStorage then
print("MWFolder Found; RepStorage")
end
Dev log doesn’t seem to be printing what I’ve told it to print. Does anyone know if I formatted this wrong or something?
GetDescendants returns an array of instances. An array doesn’t have a ‘Parent’
Also the format is local MWFolder = workspace["MainWorld"]:GetDescendants()
I’m not trying to get the descendants of MainWorld, though. I’m trying to find the folder MainWorld wherever it is in the game. For example if I were to more it to replicatedstorage.
I see. How would I turn this into a local though, so I can use it later? The ultimate goal of this is to pull things in and out of ReplicatedStorage, so I need to be able to reference the object no matter where it is.
You can use @Blokav’s solution or if you know where it will be parented first reference it from the initial parent and then parent it wherever you want.
Tried that, but when I reparent it the locals no longer work. If I say that MainWorld is a child of Workspace and I change the parent to ReplicatedStorage, the local won’t be able to find MainWorld in Workspace anymore.