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

Teleporting to another place in game troubles?

Asked by 6 years ago

Note FE is on

So basicly I am making A lobby to join different places in a game, kind of like APOC Rising but as USA and UK players are placed in different servers because god knows why I have trouble getting friends to join the same server instance I have set up.

All that aside what I am attempting to accomplish is so a player can enter in a username in a textbox and then press a "Follow Friend" button and be teleported to that person's place and server instance.

The issue is that is does not the player to the friend and it gives no reason as to why.

Client Script:

local TeleportService = game:GetService("TeleportService")
local FriendsID = script.Parent.BoxUserNameHere

function ButtonPressed()
    local FindThisUser = FriendsID.Text
    print("UserName:" .. FindThisUser)
    local UserID = game.Players:GetUserIdFromNameAsync(FindThisUser)
    print("UserID:" .. UserID)
    wait()
    game.ReplicatedStorage.RemoteFollowFriend:InvokeServer(UserID)
end

pcall(script.Parent.MouseButton1Click:connect(ButtonPressed))

Server Script:

local TeleportService = game:GetService("TeleportService")
------------------------------------------
game.ReplicatedStorage.RemoteFollowFriend.OnServerInvoke = function(player, FriendUserID)
    print(FriendUserID)
    local success, errorMsg, placeId, instanceId = TeleportService:GetPlayerPlaceInstanceAsync(FriendUserID)
    if success then
        wait(1)
        TeleportService:TeleportToPlaceInstance(placeId, instanceId, player)
    else
        print("Teleport error: ", errorMsg)
    end
end

When the friend is in a place inside of the game and the script attempts to teleport them I get this Output:

Teleport error:

I know this is pretty complex and can be stressful, it is very much for me, but any help or suggestions would greatly be appreciated :/

Answer this question