local nowMap = workspace.Maps:GetChildren()
local players = game.Players:GetChildren()
for i = 1,#players do
if players[i].Character ~= nil then
local nowMap = nowMap.MapTeleports:GetChildren()
local spawnLocation = math.random(1,#nowMap.MapTeleports:GetChildren())
players[i].Character:MoveTo(spawnLocation.Position)
players[i].Character.Parent = workspace.Ingame
end
end
Attempt to index nil with 'GetChildren'?
4 answers
You're problem is coming from this line:
local nowMap = workspace.Maps:GetChildren()
In line 7, you attempt to use this variable nowMap to access the spawning ports but instead you are trying to access a Table which causes you to error. :GetChildren()creates a table of all the children of that part, but doesn't apply to specific part. See what I mean?
You'll need to change or add a variable that references the specifc map, or the spawn ports, so you can appropriately acess them. So by, let's say, changing your nowMap variable by removing the :GetChildren() could solve your issue or creating a new variable that is assigned to the spawn ports (without the :GetChildren() part). Hope this Helps! :)
-Audiimo
Im having this problem with :WaitForChild.
local nowMap = workspace.Maps:GetChildren()
local players = game.Players:GetChildren()
for i = 1,#players do
if players[i].Character ~= nil then
local nowMap = nowMap.MapTeleports:GetChildren()
local spawnLocation = math.random(1,#nowMap.MapTeleports:GetChildren())
players[i].Character:MoveTo(spawnLocation.Position)
players[i].Character.Parent = workspace.Ingame
end
end
im not sure what u are trying to do here u get the children of nowmap in the firstline and then u try to use nowmap again so ur bassicly doing this
workspace.Maps:GetChildren().MapTeleports:GetChildren()
what are u exactly trying to do here? if u just want to get the children of MapTeleports u could do this
workspace.Maps.MapTeleports:GetChildren()
Hmm i Noticed That You Refrenced nowMap To Multiple Objects Not Just One
local nowMap = worspace.Maps:GetChildren()
Is That Intended? If It Is Then, You Can Use In Pairs Loop Instead, Reply With More Info About Your code And i'll Hopefully Respond With A Solution. , Theres Another Mistake You Refrenced nowMap Twice Which Changed nowMap's Original Refrence Perhaps Change line (07) local nowMap to another name? Because I Dont Think You Can Refrence One local to More than One Object.
3 comments
This code is wrong.
You misspelled workspace
And I believe you can store multiply variables.
This discussion is preserved as it was. New answers, comments, and votes are closed.

4 comments
Wait Which Line Is The Error in? There Are More GetChildren()'s then 1
line 07
You made a very simple mistake its because MapTeleport hasn't been defined. What I mean by that is your storing a function :GetChildren to your script which will cause an error
And its best to use a generic for loops as this will repeat the action for a period of time. And loop through the objects.