✓ Accepted answer
Is newmap an object or a function? If it's a function, you'd have to make the function return the map name, and set that return as a variable. Like this:
function getNewMap()
for i, map in pairs(game.ServerStorage:children()) do
local mapName = map.Name
map.Name = i
local newMap = game.ServerStorage:FindFirstChild(math.random(1,5)
newMap.Name = mapName
return newMap.Name
end
end
local gameMap = game.ServerStorage:WaitForChild(getNewMap())
if gameMap then
local spawns = gameMap:WaitForChild("Spawns")
end
This is just something I thought up. IT might not work.
2 comments
You are calling it on newmap - the Instance that isn't in a DataModel. Do a check to make sure newmap actually exists.
I have it set. newmap just gets a map from maps in serverstorage. A Map say is called Grass and inside it is a group called Spawns. I don't know why it says that