01 | local nowMap = workspace.Maps:GetChildren() |
02 |
03 | local players = game.Players:GetChildren() |
04 | for i = 1 ,#players do |
05 |
06 | if players [ i ] .Character ~ = nil then |
07 | local nowMap = nowMap.MapTeleports:GetChildren() |
08 | local spawnLocation = math.random( 1 ,#nowMap.MapTeleports:GetChildren()) |
09 | players [ i ] .Character:MoveTo(spawnLocation.Position) |
10 | players [ i ] .Character.Parent = workspace.Ingame |
11 | end |
12 | 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
01 | local nowMap = workspace.Maps:GetChildren() |
02 |
03 | local players = game.Players:GetChildren() |
04 | for i = 1 ,#players do |
05 |
06 | if players [ i ] .Character ~ = nil then |
07 | local nowMap = nowMap.MapTeleports:GetChildren() |
08 | local spawnLocation = math.random( 1 ,#nowMap.MapTeleports:GetChildren()) |
09 | players [ i ] .Character:MoveTo(spawnLocation.Position) |
10 | players [ i ] .Character.Parent = workspace.Ingame |
11 | end |
12 | 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
1 | 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
1 | workspace.Maps.MapTeleports:GetChildren() |
Hmm i Noticed That You Refrenced nowMap To Multiple Objects Not Just One
1 | 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.