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

How to send players to private server when they are invited?

Asked by 2 years ago
Edited 2 years ago

How can I make a Separate game instance send an invite to a player and have that player join the person who sent the invite

So in my game, you start on a base plate but get teleported to another private server instently using "TelportService:ReserveServer". From there you invite your friend using "SocialService". If your friend joins via the invite you sent have them get instantly teleported to your server instead of their own.

Tp Script:

local TelportService = game:GetService("TeleportService")
game.Players.PlayerAdded:Connect(function(plr)
    local Code = TelportService:ReserveServer(9369914616)
    TelportService:TeleportToPrivateServer(9369914616, Code, {plr})
end)

SocialService Promt Script:

local Button = script.Parent
local Player = game.Players.LocalPlayer
local SocialService = game:GetService("SocialService")
function OnButtonPressed()
    local success, results = pcall(
        function()
            return SocialService:CanSendGameInviteAsync(Player)
        end)
    if results == true then
        SocialService:PromptGameInvite(Player)      
    end
end
Button.MouseButton1Click:Connect(OnButtonPressed)

Note: the "SocialService" script is in the private server and the TP script is in the main one

Answer this question