I have cloned a part to workspace inside a folder named mapHolder. Anyways there are spawns in there that I am trying to make every player teleport to, however, this will not work and there are no errors.
Teleport code:
-- this code should teleport a player to a random spawn part on the map
-- mapSelected is a string value which indeed holds the name of the map
function teleportPlayers()
for i,v in pairs(allPlayers) do
wait()
if allPlayers[v] ~= nil then
print("Player is there")
if allPlayers[v].Character ~= nil then
print("Character is there")
if allPlayers[v]:FindFirstChild("Humanoid").Health ~= 0 then
print("Player is alive")
local mapSpawns = mapHolder[mapSelected.Value]:FindFirstChild("Spawns"):GetChildren()
allPlayers[v].Character:FindFirstChild("HumanoidRootPart").CFrame = mapSpawns[math.random(1, #mapSpawns)].CFrame-- + Vector3.new(0, 3, 0)
end
end
end
end
end

2 comments
Weird, it still doesn't work.
Fixed it.... allPlayers I guess was the problem instead I just did game.Players:GetChildren()