Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

Map Changer Script not running properly , Help please?

Asked by 6 years ago

Hi I am currently trying to create a map changer script... When I come to run it , it doesn't work. The script comes with a Round system as well which teleports people to the maps and back. Help me find this error please! Script :

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 = {}


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

--Load the map
function loadMap()
 local map = game.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 * CFrame.new(math.random(5,10),0,math.random(5,10))
  end
end


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


while true do
 wait(3)
 choosemap()
 loadMap()
 wait(1)
 teleportPlayers()
 wait(10)
 deleteMap()
 teleportBack()
end?
0
im very new and i dont understand nothing of the script, maybe there was a () in while true do, because i think it was while true do(), otherwise than that i started scripting a month ago so i dunno SuperBeeperman 30 — 6y
0
There is no () in while true do ItsArkum 42 — 6y

1 answer

Log in to vote
0
Answered by
522049 152
6 years ago
Edited 6 years ago
--Load the map
function loadMap()
 local map = game.Lighting.Maps:FindFirstChild(chosenmap.Value)
 if map then
    local mapclone = map:Clone()
    mapclone.Parent = currentmap
    mapclone:SetPrimaryPartCFrame(CFrame.new(0,0,0))
  end
end


function teleportPlayers()
 for i,v in pairs(game.Players:GetChildren())do
  v.Character.HumanoidRootPart.CFrame = currentmap:FindFirstChild(chosenmap.Value).Spawn.CFrame * CFrame.new(math.random(5,10),0,math.random(5,10))
  end
end

Replace line 19-23 and 35-39

Ad

Answer this question