Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

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

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.

2 comments

0

You are calling it on newmap - the Instance that isn't in a DataModel. Do a check to make sure newmap actually exists.

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

1 answer

✓ 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) --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 comment

1

Thanks :P

This discussion is preserved as it was. New answers, comments, and votes are closed.