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

How do I keep track of the player when I teleport him/her? (HTTP 500 User if Offline)

Asked by
jellp 0
8 years ago

I'm trying to match a group of players together and put them together in one place. However, when I try to receive information of the player joining the game, I receive this error: HTTP 500 (HTTP/1.1 500 User is offline)

I've used a bit from the Matchmaking tutorial on the roblox wiki in order to make this code and I understand most of it I think. I can't figure out why the user is apparantely offline though.

if #playernamelist > 1 and att.Value > 2 then

    joinlist = {playernamelist[1], playernamelist[2]}
    table.remove(playernamelist, 1)
    table.remove(playernamelist, 1)

    id = joinlist[1].UserId

    local match = game:GetService("AssetService"):CreatePlaceAsync("2 player match", 243740040)

    print(match)



    wait(5)

    local connection = joinlist[1].OnTeleport:connect(function(teleportState, placeId)
    if teleportState == Enum.TeleportState.Started then
        local teleportStarted = os.time()
        -- Keep checking if playerA has arrived in other instance.
        wait(3)
        while true do
            local success, error, placeId, arenaInstanceId = teleportService:GetPlayerPlaceInstanceAsync(id)

            print(success)
            print(error)
            print(placeId)
            print(arenaInstanceId)



            -- If playerA is in the correct place then we can teleport playerB there as well
            if placeId == 243740040 then
                teleportService:TeleportToPlaceInstance(placeId, arenaInstanceId, joinlist[2])
                return
            end
            wait()
        end 
    end
end)
wait(1)

    -- Teleport playerA to the arena
    teleportService:Teleport(243740040, joinlist[1])

    att.Value = 0

end

1 answer

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

I've managed to get this fixed myself eventually: This error seems to happen before the new place starts loading but after the place got requested. In order to fix this I use pcall to keep trying to join, igoring the error. This eventually properly returns the instance so you can make players join the same game.

Here is the code that is fixed, do note that it has some indenting errors as this is in the middle of the script.

if #playernamelist > 1 and att.Value > 2 then

                joinlist = {playernamelist[1], playernamelist[2]}
                table.remove(playernamelist, 1)
                table.remove(playernamelist, 1)

                id = joinlist[1].UserId

                )

                local match = game:GetService("AssetService"):CreatePlaceAsync("Bomberblox 2 player match", 243740040)

                print(match)





                local connection = joinlist[1].OnTeleport:connect(function(teleportState, placeId)
                if teleportState == Enum.TeleportState.Started then
                    local teleportStarted = os.time()
                    -- Keep checking if playerA has arrived in other instance.

                    wait(5)

                    while true do

                        pcall( --Then let's just force it.
                        function()
                        local success, error, placeId, arenaInstanceId = teleportService:GetPlayerPlaceInstanceAsync(id)

                        print(success)
                        print(error)
                        print(placeId)
                        print(arenaInstanceId)

                        --workspace.Message.Text = "success: " + tostring(success) + ". error: " + error + ". placeId: " + tostring(placeId) + ". Instance: " + tostring(arenaInstanceId)

                        -- If playerA is in the correct place then we can teleport playerB there as well
                        if placeId == match then
                            teleportService:TeleportToPlaceInstance(placeId, arenaInstanceId, joinlist[2])
                            return
                        end

                        end)                        

                        wait(1)
                    end 
                end
            end)
            wait(1)

                -- Teleport playerA to the arena 
                teleportService:Teleport(match, joinlist[1])

                att.Value = 0

            end
Ad

Answer this question