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

Can someone fix my map script?

Asked by 9 years ago

This is what I have in my Workspace and ServerScriptService:

Workspace
    MapHolder
        Map1Beginner
        Map2Turning

ServerScriptService
    Maps(script)
        Map1(script)
        Map2(script)

This is the script for making one script enable and the other one disabled

local Map1 = game.ServerScriptService.Maps.Map1
local lobbySpawn = game.Workspace.LobbySpawn
local Map2 = game.ServerScriptService.Maps.Map2

function Map1(Beginner)
    Map1.Disabled = true
    wait()
    Map1.Disabled = false
end

function teleportPlayers(target)
    for _, player in pairs(game.Players:GetChildren()) do
            while player.Character == nil do
                wait()
            end
        local character = player.Character
        local torso = character:WaitForChild("Torso")
        torso.CFrame = target.CFrame
    end
end

wait(10)

function Map2(Turning)
    Map2.Disabled = true
    wait()
    Map2.Disabled = false
end

function teleportPlayers(target)
    for _, player in pairs(game.Players:GetChildren()) do
            while player.Character == nil do
                wait()
            end
        local character = player.Character
        local torso = character:WaitForChild("Torso")
        torso.CFrame = target.CFrame
    end
end

wait(10)

while true do
    -- Map1: Beginner
    Map1()

    -- teleport all players to the lobby
    teleportPlayers(lobbySpawn)

    wait(10)

    -- Map2: Turning
    Map2()

    -- teleport all players to the lobby
    teleportPlayers(lobbySpawn)

    wait(10)

end

What I am trying to do is make it where, when two players join they will spawn to the first map, and then after the race, they will get spawned or teleported to the lobby and wait 10 for the next map, and then they go to map 2. Then they start over. The Map1 and Map2 script are about the same.

Answer this question