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

How to make a friend teleport script in the same universe? (Issues)

Asked by
Radstar1 270 Moderation Voter
7 years ago
Edited 7 years ago

PROBLEM It only allows me to teleport to people in the exact same server that i'm trying to teleport from. useless right? I would greatly appreciate some help.

DESC I tried to make a feature that uses the typed name of a player, fires it to the server, and gets their UserId to begin the first part.

1--Gets the userId of "Who"
2game.ReplicatedStorage.Events.TeleportToFriend.OnServerEvent:Connect(function(Player,Who)
3`   local FriendId
4    pcall(function()
5        FriendId = game.Players:GetUserIdFromNameAsync(Who)
6    end)
7    FollowFriend(Player,FriendId) -- Function that makes you follow your friend
8end)

The second part of the script is the one following the friend's named they typed.

1function FollowFriend(player, targetUserId)
2    local teleportService = game:GetService("TeleportService")
3    local success, errorMsg, placeId, instanceId =      teleportService:GetPlayerPlaceInstanceAsync(targetUserId)
4    if success then
5        teleportService:TeleportToPlaceInstance(placeId, instanceId, player)
6    else
7        print("Teleport error:", errorMsg)
8    end
9end

However this is where it won't let me teleport to anyone outside of my server?

Any suggesstions? Any help appreciated

1
lmao much appreciate<3 Radstar1 270 — 7y
1
Gonna test the problem, might take some time User#20388 0 — 7y
0
Much obliged man Radstar1 270 — 7y
0
You are not doing anything if GetUserIdFromNameAsync fails and you are not pcalling GetPlayerPlaceInstanceAsync. Use "pcall(teleportService.GetPlayerPlaceInstanceAsync, teleportService, targetUserId)" hiimgoodpack 2009 — 6y

1 answer

Log in to vote
0
Answered by 6 years ago
Edited 6 years ago

Try using the IsFriendsWith() statement, shown in an example here: wiki.roblox.com/index.php?title=API:Class/Player/IsFriendsWith

Ad

Answer this question