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
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
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.