I'm making a game that has rounds where it loads in the new map, teleports all the players there, teleports them back to the lobby, then deletes the map. In workspace I have a folder called "CurrentMap" and a string value called "ChosenMap" inside the script. All the maps are in lighting until they're supposed to be moved to workspace.
Here's the video I was using for help - https://www.youtube.com/watch?v=VpMDfiR6MwM&t=157s
local players = game.Players:GetChildren()
local maps = game.Lighting.Maps:GetChildren()
local currentmap = game.Workspace:WaitForChild("CurrentMap")
local chosenmap = script:WaitForChild("ChosenMap")
local spawner = game.Workspace:WaitForChild("Spawn")
local choices = {}
--Choose a random map
function chooseMap()
for i = 1,#maps do
if maps [i]:isA("Model") then
table.insert(choices,maps[i])
end
end
local picked = math.random(1,#maps)
chosenmap.Value = choices[picked].Name
--Loading in the maps
function loadMap()
local map = game.Lighting.Maps.FindFirstChild(chosenmap.Value)
map:Clone().Parent = currentmap
end
--Deleting the maps
function deleteMap()
for i,v in pairs(currentmap:GetChildren())do
if v:isA("Model")then
v:Destroy()
end
end
end
--Teleporting the players
function teleportPlayers()
for i,v in pairs (players)do
v.Character.HumanoidRootPart.CFrame =
currentmap:FindFirstChild(chosenmap.Value).Spawn.CFrame
*CFrame.new(math.random(5,10),0,math.random(5,10))
end
end
--Teleporting Players Back
function teleportBack()
for i,v in pairs(players)do
v.Character.HumanoidRootPart.CFrame =
spawner.SpawnLocation.CFrame*CFrame.new(math.random(5,10),0,math.random(5,10))
end
end
--The whole cycle
while true do
wait(3)
chooseMap()
loadMap()
wait(1)
teleportPlayers()
wait(10)
deleteMap()
teleportBack()
end
If anyone could fix this for me, that would be great! My friend and I are new to scripting so we're still using lots of guides. So if there's anything else you think we should check out to improve our skills, that would be much appreciated! Thanks.

2 comments
On line 23, you did ".FindFirstChild", It's supposed to be ":FindFirstChild".
yea you did