Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

WaitForChild called on an Instance that is not in a DataModel?

Asked by 10 years ago

WaitForChild called on an Instance that is not in a DataModel.

local spawnsmodel = newmap:WaitForChild("Spawns")

It seems to not know what Spawns is. This is based of the Mad Bloxxer Vids, and my game was working but today when I go to play it has this. Anyone help.

0
You are calling it on newmap - the Instance that isn't in a DataModel. Do a check to make sure newmap actually exists. Ravenshield 180 — 10y
0
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 NinjoOnline 1146 — 10y

1 answer

Log in to vote
2
Answered by 10 years ago

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) --change 5 to how many maps there are
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.

1
Thanks :P NinjoOnline 1146 — 10y
Ad

Answer this question