I am trying to create a randomized spawn for a map in my game, but the script does not recognize that the parts even exist. I printed the table length and table, both were 0/no elements.
Here’s my code:
local MapSpawns = game.Workspace:WaitForChild("MountainMap"):WaitForChild("SpawnLocations"):GetChildren()
print("LENGTH OF SPAWN LOCATIONS = " .. tostring(#MapSpawns), MapSpawns)
plr.Character:MoveTo(MapSpawns[math.random(1, #MapSpawns)].Position)
local Map = game.Workspace:WaitForChild("MountainMap")
local Spawns = Map:WaitForChild("SpawnLocations")
print("lenght : "..#Spawns)
local Character = plr.Character
Character:PivotTo(Spawns[math.random(1, #Spawns)].CFrame)