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

I am having trouble making a script to teleport players to different maps, how would I fix this?

Asked by 8 years ago

Hello! I'm making a game where the players need to be teleported to a map after the script chooses the map. The problem is when I run the game, absolutely nothing happens. How would I go about fixing this? Thanks for stopping by! Here is the script:

local Map1 = game.lighting.Map1
local Map2 = game.lighting.Map2
local Map3 = game.lighting.Map3

function ChooseMap()
    while true do
    wait(5)
    ChooseMap = math.random(1,3)
    if ChooseMap == 1 then
        game.lighting.Map1:Clone(game.workspace)
    for _, plr in pairs(Game:GetService("Players"):GetPlayers()) do
        if plr.Character then
            plr.Character:MoveTo(Vector3.new(14.31, 1.61, -151.635))
wait(10)
Map1:Destroy()
    end
        if ChooseMap == 2 then
        game.lighting.Map2:Clone(game.workspace)
         for _, plr in pairs(Game:GetService("Players"):GetPlayers()) do
        if plr.Character then
            plr.Character:MoveTo(Vector3.new(23.1, 38.74, 117.9))
    wait(10)
Map2:Destroy()
end
    if ChooseMap == 3 then
        game.lighting.Map3:Clone(game.workspace)
         for _, plr in pairs(Game:GetService("Players"):GetPlayers()) do
        if plr.Character then
            plr.Character:MoveTo(Vector3.new(23.1, 72.26, 117.9))
wait(10)
Map3:Destroy()
wait(10)
    end
end
end
    end
end
end
    end
    end
end






1 answer

Log in to vote
0
Answered by 8 years ago
Edited 8 years ago

The problem is you haven't made the function triggered :l

I recommend you recommend you removing the function part or just copy the script I fixed for you

local Map1 = game.Lighting.Map1

local Map2 = game.Lighting.Map2

local Map3 = game.Lighting.Map3


while true do

wait(5)

ChooseMap = math.random(1,3)

if ChooseMap == 1 then

    map1z = game.Lighting.Map1:clone()
    map1z.Parent = game.Workspace

for _, plr in pairs(game:GetService("Players"):GetPlayers()) do

    if plr.Character then

        plr.Character:MoveTo(Vector3.new(14.31, 1.61, -151.635))

      wait(10)

     map1z:Destroy()

end

    if ChooseMap == 2 then

    map2z = game.Lighting.Map2:clone()
    map2z.Parent = game.Workspace

     for _, plr in pairs(game:GetService("Players"):GetPlayers()) do
    if plr.Character then
        plr.Character:MoveTo(Vector3.new(23.1, 38.74, 117.9))
 wait(10)
 map2z:Destroy()
end
  if ChooseMap == 3 then
     map3z = game.Lighting.Map3:clone()
     map3z.Parent = game.Workspace
      for _, plr in pairs(game:GetService("Players"):GetPlayers()) do
      if plr.Character then
        plr.Character:MoveTo(Vector3.new(23.1, 72.26, 117.9))
       wait(10)
       map3z:Destroy()
      wait(10)
  end
 end
 end
  end
 end
 end
  end
  end
Ad

Answer this question