SocialService 는 Roblox 플랫폼에서 관계를 만드는 소셜 기능을 간편하게 만듭니다. 주요 사용은 플레이어에게 초대 요청을 보내고 전화 책에 저장하여 친구들과 관계를
요약
메서드
이벤트
플레이어의 초대 상태가 변경될 때 발생합니다.
플레이어가 초대 프롬프트를 닫을 때 화재됩니다.
플레이어가 전화 책 프롬프트를 닫을 때 화재됩니다.
콜백
전화 목록에서 전화를 받을 때의 콜백.
속성
메서드
HideSelfView
호출 플레이어의 자신 뷰를 숨깁니다. 이 메서드를 호출하면 자신 뷰가 이미 숨겨져 있더라도 작동하지 않습니다.
반환
PromptGameInvite
PromptGameInvite() 는 로컬 플레이어를 통해 친구를 현재 경험에 초대하도록 하는 초대 프롬프트를 표시합니다. 이 메서드를 호출하기 전에 Class.SocialService:CanSendGameInviteAsync()|CanSendGameInviteAsync

초대 프롬프트 구현, 사용자 지정 프롬프트 사용 및 시작 데이터 사용에 대한 자세한 내용은 Player Invite Prompts를 참조하십시오.
매개 변수
Class.Player 를 클릭하여 초대 팝업을 표시합니다.
프롬프트를 사용자 정의하기 위한 옵션 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 에 대한 지정된 전화기 책을 전송합니다. 플레이어가 누군가를 전화하기로 선택하면 Class.SocialService.CallInviteState
플레이어가 전화 책을 열 자격이 없으면 오류 대화 상자가 표시됩니다.
이 메서드의 샘플 구현은 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 를 반환합니다. 항상 이 메서드
플레이어 초대 프롬프트를 구현하는 방법에 대한 자세한 내용은 플레이어 초대 프롬프트 를 참조하십시오.
매개 변수
Class.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
이 이벤트는 플레이어의 초대 상태가 변경될 때 발생합니다.
매개 변수
새로운 호출 초대 상태입니다.
코드 샘플
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
전화 목록에서 전화를 수신할 때 처리할 콜백을 처리합니다. tag 에 설명된 대로 다른 "입점"이나 유사한 것을 구별하려면 PromptPhoneBook() 매개 변수를 사용할 수 있습니다. 단일 콜백만 설정할 수 있습니다.
매개 변수
다양한 전화 책 항목을 구별하는 데 사용되는 문자열입니다.
호출에 참여하는 모든 플레이어가 포함된 배열. 호출자는 항상 배열의 첫 번째 플레이어가 됩니다.
반환
Class.DataModel.PlaceId 및 ReservedServerAccessCode 키의 값이 Class.DataModel.PlaceId 및 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