I’m creating a join friend system in a game, and to join a player you write their name in a text box and press confirm, however the teleport fails and says " Attempted to teleport to a place that is restricted". I have allow 3rd party teleports on, and its the same game, just a different server.
local script
script.Parent.JoinFriend.Border.Confirm.MouseButton1Click:Connect(function()
local ID = game:GetService("Players"):GetUserIdFromNameAsync(script.Parent.JoinFriend.Border.TextBox.Text)
print(ID)
local success,fail = pcall(function()
game.ReplicatedStorage.Teleport:FireServer(ID)
end)
if fail then
friend.Border.TextBox.PlaceholderText = "Invalid"
wait(2)
friend.Border.TextBox.PlaceholderText = "Enter Username"
end
end)
Server Side
local rep = game.ReplicatedStorage
rep.Teleport.OnServerEvent:Connect(function(plr,ID)
local TPS = game:GetService("TeleportService")
local placeid = TPS:GetPlayerPlaceInstanceAsync(ID)
print(placeid)
TPS:TeleportToPlaceInstance(game.PlaceId,placeid,plr)
end)