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

Need help with my TeleportToPrivateServer script. Not working and I can't find an error?

Asked by 6 years ago

I am working on a matchmaking script that adds 5 players to matchmaking, it adds a name for a second and removes it the next second. No error.

local pad = game.Workspace.lobbyPad2
local boardGui = game.Workspace.board.boardGui
local adding = false
local timeing = false
local subbing = false
local plr1name = ""
local plr2name = ""
local plr3name = ""
local plr4name = ""
local plr5name = ""
local TS = game:GetService("TeleportService")
local Players = game:GetService("Players")
local DSS = game:GetService("DataStoreService")
local DS = DSS:GetGlobalDataStore()


function timer()
    if timeing == false then
        timeing = true
        boardGui.timernumber.Text = "10"
        wait(1)
        boardGui.timernumber.Text = "9"
        wait(1)
        boardGui.timernumber.Text = "8"
        wait(1)
        boardGui.timernumber.Text = "7"
        wait(1)
        boardGui.timernumber.Text = "6"
        wait(1)
        boardGui.timernumber.Text = "5"
        wait(1)
        boardGui.timernumber.Text = "4"
        wait(1)
        boardGui.timernumber.Text = "3"
        wait(1)
        boardGui.timernumber.Text = "2"
        wait(1)
        boardGui.timernumber.Text = "1"
        wait(1)
        boardGui.timernumber.Text = "Go!"
        wait(1)
        local code = DS:GetAsync("ReservedServer")
        if type(code) ~= "string" then
            code = TS:ReserveServer(game.PlaceId)
            DS:SetAsync("ReservedServer",code)
        end
        if script.one.Value == true then
            local pt1 = game.Players:getPlayerFromCharacter(plr1name)
            TS:TeleportToPrivateServer(982371689,code,{pt1})
        end
        if script.two.Value == true then
            local pt2 = game.Players:getPlayerFromCharacter(plr2name)
            TS:TeleportToPrivateServer(982371689,code,{pt2})
        end
        if script.three.Value == true then
            local pt3 = game.Players:getPlayerFromCharacter(plr3name)
            TS:TeleportToPrivateServer(982371689,code,{pt3})
        end
        if script.four.Value == true then
            local pt4 = game.Players:getPlayerFromCharacter(plr4name)
            TS:TeleportToPrivateServer(982371689,code,{pt4})
        end
        if script.five.Value == true then
            local pt5 = game.Players:getPlayerFromCharacter(plr5name)
            TS:TeleportToPrivateServer(982371689,code,{pt5})
        end
        boardGui.player1.Text = ""
        boardGui.player2.Text = ""
        boardGui.player3.Text = ""
        boardGui.player4.Text = ""
        boardGui.player5.Text = ""
        script.one.Value = false
        script.two.Value = false
        script.three.Value = false
        script.four.Value = false
        script.five.Value = false
        plr1name = ""
        plr2name = ""
        plr3name = ""
        plr4name = ""
        plr5name = ""
        boardGui.timernumber.Text = "10"
        timeing = false
        wait(1)
    end
end

function stepOn(player)
    if adding == false then
        adding = true
        if player.Parent.Humanoid then
            local bool = game.Players:GetPlayerFromCharacter(player.Parent).PlayerGui.boolCheck.Value
            if script.one.Value == false then
                bool = true
                script.one.Value = true
                boardGui.player1.Text = player.Parent.Name
                plr1name = player.Parent
                timer()
                adding = false
            end
            if script.one.Value == true then
                if script.two.Value == false then
                    bool = true
                    script.two.Value = true
                    boardGui.player2.Text = player.Parent.Name
                    plr2name = player.Parent
                    adding = false
                end
            end
            if script.two.Value == true then
                if script.three.Value == false then
                    bool = true
                    script.three.Value = true
                    boardGui.player3.Text = player.Parent.Name
                    plr3name = player.Parent
                    adding = false
                end
            end
            if script.three.Value == true then
                if script.four.Value == false then
                    bool = true
                    script.four.Value = true
                    boardGui.player4.Text = player.Parent.Name
                    plr4name = player.Parent
                    adding = false
                end
            end
            if script.four.Value == true then
                if script.five.Value == false then
                    bool = true
                    script.five.Value = true
                    boardGui.player5.Text = player.Parent.Name
                    plr5name = player.Parent
                    adding = false
                end
            end
        end
    end
end

function stepOff(player)
    local char = player.Parent
    wait(.1)
    local name = char.Name
    if boardGui.player1.Text == player.Parent.Name then
        boardGui.player1.Text = ""
        script.one.Value = false
        plr1name = ""
    end
    if boardGui.player2.Text == player.Parent.Name then
        boardGui.player2.Text = ""
        script.two.Value = false
        plr2name = ""
    end
    if boardGui.player3.Text == player.Parent.Name then
        boardGui.player3.Text = ""
        script.three.Value = false
        plr3name = ""
    end
    if boardGui.player4.Text == player.Parent.Name then
        boardGui.player4.Text = ""
        script.four.Value = false
        plr4name = ""
    end
    if boardGui.player5.Text == player.Parent.Name then
        boardGui.player5.Text = ""
        script.five.Value = false
        plr5name = ""
    end
end

script.Parent.Touched:connect(stepOn)
game.Workspace.offTouch.Touched:connect(stepOff)

Thanks!

Answer this question