So I am trying to find an inserted (or cloned) model in the workspace and get it's children then, I'm trying to get a random child from that and using "MoveTo" move the players character that clicked the button to it. I keep getting errors because if I use some thing like this:
local SpawnModel = game.Workspace:WaitForChild("SpawnsForMap1" or "SpawnsForMap2"):GetChildren()
-- it always waits for the first model and never reads the next part
-- or use this, after disabling the script and re-enabling it with another script:
local SpawnModel = game.Workspace:findFirstChild("SpawnsForMap1" or "SpawnsForMap2"):GetChildren()
-- same issue for this one except it outputs an error because it's not waiting it's searching and returning it found nothing for a reason I'm stumped by
--Error: attempt to index a nil value
-- I know what this means but don't understand how I can fix it to make it look for a set of models and only that set and if it finds one model return that model's children so the rest of the script can function and move the player to a random brick
So, could anyone let me know what I can use here that allows me to search for a lot of models but once it finds one that exists it returns that to continue the rest of the script? I feel as though I may be close to an answer but I'm not exactly sure. Would using something like this work or, something completely different?:
local SpawnModel = repeat game.Workspace:FindFirstChild("MapSpawnsName1" or "MapSpawnsName2" ) until return
--Yes I know this doesn't work but I'm not sure what would...
Other:
local Maps = {"Map1","Map2" }
local SpawnPos
local found = false
while found == false do
local work = game.Workspace
for _, v in pairs (Maps) do
if found == false then
if work:FindFirstChild(v) then
found = true
print (v)
wait()
SpawnPos = v:GetChildren()
end
end
end
wait()
end
--Error: attempt to call method 'GetChildren' (a nil value)
--I'm assuming somehow I need to iterate this so I recognizes it is a model or something?
--EDIT: Fixed the error by declaring that v = work:FindFirstChild(v) after actually finding it.
Thanks for any help!

5 comments
Thanks, but I wanted to get the children inside that model, apparently after some testing I get several errors, do you know how this would work with ":GetChildren()"? Because what I want to do it get the children inside the model and use math.random to select one of them (I've already got the random selection figured out.
Something like this spawnModel = work:GetChildren(v) gives me an error: attempt to get length of upvalue 'spawnModel' (a nil value) .
Nevermind, I think I can work this through thanks very much!
ill edit
See Other code in original post is what I've gotten.