local Players = game:GetService("Players")
local maps = game.ReplicatedStorage.Maps:GetChildren()
local map = maps[math.random(1, #maps)]
map.Parent = workspace
local Connections = {}
local function PlayerAdded(player)
if not Connections[player.Name] then
print(player.Name.." has entered the server.")
local function CharacterAdded(character)
print(character.Name.."'s Character has loaded.")
local spawns = false
for k,v in pairs(map:GetChildren()) do
if v.Name:find("Spawn") then
spawns = v:GetChildren()
break
end
end
if spawns and #spawns > 0 then
local hrp = character:WaitForChild("HumanoidRootPart")
hrp.CFrame = spawns[math.random(1,#spawns)].CFrame + Vector3.new(0,3,0)
end
end
CharacterAdded(player.Character or player.CharacterAdded:Wait())
Connections[player.Name] = player.CharacterAdded:Connect(CharacterAdded)
end
end
Players.PlayerAdded:Connect(PlayerAdded)
for _,player in pairs(Players:GetPlayers()) do
spawn(function() PlayerAdded(player) end)
end