Error is on line 54
local players = game.Players:GetChildren()
local maps = game.Lighting:GetChildren()
local currentmap = game.Workspace:WaitForChild("CurrentMap")
local chosenmap = Script.Workspace:WaitForChild("ChosenMap")
local spawner = game.Workspace:WaitForChild("Spawn")
local choices = {}
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
end
function loadMap()
local map = gam.Lighting.Maps:FindFirstChild(chosenmap.Value)
map:Clone().Parent = currentmap
end
function deleteMap()
for i,v in pairs(currentmap:GetChildren()) do
if v:isA("Model") then
v:Destroy()
end
end
end
function teleportPlayers()
for i,v in pairs(players) do
v.Character.HumanoidRootPart.CFrame = currentmap:FindFirstChild(chosenmap.Value).Spawn * CFrame.new(math.random(5,10),0,math.random(5,10))
end
end
function teleportBack()
for i,v in pairs(players) do
v.Character.HumaniodRootPart.CFrame =
spawner.SpawnLocation.CFrame *
CFrame.new(math.random(5,10),0,math.random(5,10))
end
end
while true do
wait(3)
chooseMap()
loadMap()
wait(1)
teleportPlayers()
wait(10)
deleteMap()
teleportBack()
end
I get this error in the output/console
07:02:08.573 - Workspace.map:60: unexpected symbol near '?'
What am I doing wrong here?

6 comments
It errors because there's a random question mark after the 'end' on line 54
on line 54, why you type "?" (Question mark)? you don't need to type here.
that was never there in the original script, must of accidentally put that there while writing this question
On lines 8, 18, 23, 31, 37 you're polluting the global namespace
and how would I fix it?
It should be local. Don't use global scoping, as it's not such a good practice.