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

Cannot teleport player to reserve server?

Asked by 4 years ago

I am creating a story game and I want to teleport to a reserve server so that no one else join the server. Not even the player's friends unless they were on the same bus. I have 2 places in the same game that I own. The API services and HTTP requests are all turned on. I looked in the wiki and used the syntax for the function yet I still get this error:09:29:29.978 - Teleport to ReservedServer failed : HTTP 403 (Forbidden). Here's my code:

local label = script.ScreenGui.TextLabel
local secondsLeft = 10
local TeleportService = game:GetService("TeleportService")
local placeID_1 = 5143051429
local Players = game:GetService("Players")
local DSS = game:GetService("DataStoreService")
local DS = DSS:GetGlobalDataStore()

while wait(1) do
    label.Text = "Buses leaving in: " .. secondsLeft
    secondsLeft-=1
    if secondsLeft==0 then
        wait(1)
        label.Text = "Teleporting..."
        part = workspace.Teleport1
        local min = part.Position - (0.5 * part.Size)
        local max = part.Position + (0.5 * part.Size)
        local region = Region3.new(min, max)
        local parts = workspace:FindPartsInRegion3(region, part, 100000)
        for count = 1, #parts do
            local hit = parts[count]
            local char = hit.Parent
            local player = game.Players:GetPlayerFromCharacter(char)
            local humanoid = char:FindFirstChild("Humanoid")
            local code = DS:GetAsync("ReservedServer")
            if player~=nil then
                local code = DS:GetAsync("ReservedServer")
                if type(code) ~= "string" then
                    code = TeleportService:ReserveServer(math.random(1000, 1000000))
                    DS:SetAsync("ReservedServer",code)
                end
                TeleportService:TeleportToPrivateServer(5143051429,code,{player})
            end

        end
        part = workspace.Teleport2
        local min = part.Position - (0.5 * part.Size)
        local max = part.Position + (0.5 * part.Size)
        local region = Region3.new(min, max)
        local parts = workspace:FindPartsInRegion3(region, part, 100000)
        for count = 1, #parts do
            local hit = parts[count]
            local char = hit.Parent
            local player = game.Players:GetPlayerFromCharacter(char)
            local humanoid = char:FindFirstChild("Humanoid")
            local plr = {}
            local code = DS:GetAsync("ReservedServer")
            if player~=nil then
                local code = DS:GetAsync("ReservedServer")
                if type(code) ~= "string" then
                    code = TeleportService:ReserveServer(math.random(1000, 1000000))
                    DS:SetAsync("ReservedServer",code)
                end
                TeleportService:TeleportToPrivateServer(5143051429,code,{player})
            end
        end
        wait(1)
        secondsLeft=10
    end
end

I have also tried to test in Roblox Player but it always also doesn't work there. I am very frustrated and if anyone can help it would be REALLY appreciated :D!

Answer this question