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?
Simply put, the error is saying you put "?" out of nowhere, with no reasonable context. The error is saying unexpected symbol, meaning it wasn't meant to be there. Regardless of whether you say it wasn't from the original script, I'd advise you to check the script and get rid of a question if there is one.
All in all, make sure to check for any "grammatical" errors in your script.
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 -- Got rid of the question mark here.