SocialService
*このコンテンツは、ベータ版のAI(人工知能)を使用して翻訳されており、エラーが含まれている可能性があります。このページを英語で表示するには、 こちら をクリックしてください。
SocialService は、Roblox プラットフォームの関係に影響を与えるソーシャル機能を容易にします。主な使用は、招待プロンプト と電話帳をプレイヤーに表示することで、 Class.SocialService
概要
方法
イベント
プレイヤーの招待状態が変更されるときにファイアを起動します。
プレイヤーが招待プロンプトを閉じるときにファイアを起動します。
プレイヤーが電話帳のプロンプトを閉じるときに発動します。
コールバック
電話帳からの呼び出しが呼び出されたときのコールバック。
プロパティ
方法
HideSelfView
呼び出すプレイヤーの自分のビューを非表示にします。このメソッドを呼び出している間、自分のビューがすでに非表示になっている場合、それは何もしません。
戻り値
PromptGameInvite
PromptGameInvite() は、ローカルプレイヤーに招待プロンプトを表示し、そのプレイヤーの友達を現在のエクスペリエンスに招待することができます。このメソッドを呼び出す前に、 Class.SocialService:CanSendGameInviteAsync()|CanSendGameInvite

招待プロンプトの実装、カスタマイズ、通知、およびランチャデータの使用については、Player Invite Promptsを参照してください。
パラメータ
プロンプトのカスタマイズのオプション ExperienceInviteOptions オブジェクト。
戻り値
コードサンプル
The following code sample uses CanSendGameInviteAsync() to confirm whether the local Player can send an invite. If true, it then prompts the invite using PromptGameInvite().
local SocialService = game:GetService("SocialService")
local Players = game:GetService("Players")
local player = Players.LocalPlayer
-- Function to check whether the player can send an invite
local function canSendGameInvite(sendingPlayer)
local success, canSend = pcall(function()
return SocialService:CanSendGameInviteAsync(sendingPlayer)
end)
return success and canSend
end
local canInvite = canSendGameInvite(player)
if canInvite then
SocialService:PromptGameInvite(player)
end
PromptPhoneBook
プレイヤーが誰かを呼び出すと、 Player イベントが発動します。CallInviteStateChanged を使用する前
プレイヤーが電話帳を開く資格がありません、エラーダイアログが表示されます。
このメソッドのサンプル実装は、Roblox Connect を参照してください。
パラメータ
電話帳でプロンプトするプレーヤー。
異なる電話帳の "エントリポイント" または類似の項目を区別するための弦。たとえば、コールするプレイヤーのキャラクターが現在どの領域にあるかを定義する弦を渡すことができます。
戻り値
コードサンプル
The following code sample, placed within a child LocalScript of a GuiButton, uses CanSendCallInviteAsync() to confirm that the player can make a call. If so, it connects PromptPhoneBook() to the button's Activated event.
local Players = game:GetService("Players")
local SocialService = game:GetService("SocialService")
local player = Players.LocalPlayer
local button = script.Parent
button.Visible = false
-- Function to check whether the player can send a call invite
local function canSendCallingInvite(sendingPlayer)
local success, canSend = pcall(function()
return SocialService:CanSendCallInviteAsync(sendingPlayer)
end)
return success and canSend
end
local canCall = canSendCallingInvite(player)
if canCall then
button.Visible = true
button.Activated:Connect(function()
SocialService:PromptPhoneBook(player, "")
end)
end
ShowSelfView
プレイヤーの自己ビューを表示します。このメソッドが自己ビューが表示されている間に呼び出されると、何もしません。
パラメータ
自分のビューを配置する位置。
戻り値
CanSendCallInviteAsync
Class.Player が友達にコールインビテーションを送信できるかどうかを返します。このメソッドの結果を常に Player 前に使用する必要があります。電話ブックの開き方はプレイヤーによって異なるため、PromptPhoneBook()
このメソッドのサンプル実装は、Roblox Connect を参照してください。
パラメータ
戻り値
指定されたプレイヤーがコールインビテーションを送信できるかどうか。
コードサンプル
The following code sample, placed within a child LocalScript of a GuiButton, uses CanSendCallInviteAsync() to confirm that the player can make a call. If so, it connects PromptPhoneBook() to the button's Activated event.
local Players = game:GetService("Players")
local SocialService = game:GetService("SocialService")
local player = Players.LocalPlayer
local button = script.Parent
button.Visible = false
-- Function to check whether the player can send a call invite
local function canSendCallingInvite(sendingPlayer)
local success, canSend = pcall(function()
return SocialService:CanSendCallInviteAsync(sendingPlayer)
end)
return success and canSend
end
local canCall = canSendCallingInvite(player)
if canCall then
button.Visible = true
button.Activated:Connect(function()
SocialService:PromptPhoneBook(player, "")
end)
end
CanSendGameInviteAsync
CanSendGameInviteAsync() は、true を返しますが、Player が他のプレイヤーを現在のエクスペリエンスに招待できるかどうかは常にこのメソッドの結果を使用する必
プレイヤーの招待プロンプトに関する詳細は、Player Invite Prompts を参照してください。
パラメータ
オプションの Player.UserId の可能性のある 受信者 、送信者 がその特定の受信者を招待できるかどうかをチェックします。
戻り値
指定されたプレイヤーが招待状を送信できるかどうか。
コードサンプル
The following code sample uses CanSendGameInviteAsync() to confirm whether the local Player can send an invite. If true, it then prompts the invite using PromptGameInvite().
local SocialService = game:GetService("SocialService")
local Players = game:GetService("Players")
local player = Players.LocalPlayer
-- Function to check whether the player can send an invite
local function canSendGameInvite(sendingPlayer)
local success, canSend = pcall(function()
return SocialService:CanSendGameInviteAsync(sendingPlayer)
end)
return success and canSend
end
local canInvite = canSendGameInvite(player)
if canInvite then
SocialService:PromptGameInvite(player)
end
イベント
CallInviteStateChanged
このイベントは、プレイヤーの呼び出し状態が変更されると発動します。
パラメータ
Class.Player インスタンスは、Player のコール招待状態変更を持つプレイヤーのインスタンスです。
新しいコール招待状態。
コードサンプル
local SocialService = game:GetService("SocialService")
local button = script.Parent
local isPhonebookOpen = false
SocialService.CallInviteStateChanged:Connect(function(_, inviteState)
local isCalling = inviteState == Enum.InviteState.Placed
if isCalling or isPhonebookOpen then
button.Visible = false
else
button.Visible = true
end
end)
GameInvitePromptClosed
このイベントは、プレイヤーが招待プロンプトを閉じると発動します。
パラメータ
コールバック
OnCallInviteInvoked
電話帳からの呼び出しが処理されるコールバック。PromptPhoneBook() パラメーターを使用して、異なる「入力ポイント」または類似の処理を異なる "タグ" パラメーターで区別できます。Class.SocialService:PromptPhoneBook()|PromptPhoneBook() でのみコールバックを設定する定できます。
パラメータ
電話帳のエントリポイント間で異なる電話帳のエントリを区別するのに役立つストリング。
コールに関わるすべてのプレイヤーを含むアレイ。コーラーは常にアレイの最初のプレイヤーになります。
戻り値
Class.DataModel.PlaceId と ReservedServerAccessCode のキーを含む、値が DataModel.PlaceId であり、1>Class.TeleportService:ReserveServer()1> によって返されたサーバーアクセスコードです。
コードサンプル
local SocialService = game:GetService("SocialService")
local TeleportService = game:GetService("TeleportService")
SocialService.OnCallInviteInvoked = function()
local placeId = 0123456789 -- This is the place ID of the desired place to drop call participants into
local accessCode = TeleportService:ReserveServer(placeId)
return { ReservedServerAccessCode = accessCode, PlaceId = placeId }
end