学ぶ
エンジンクラス
SocialService
作成できません
サービス
複製されていません

*このコンテンツは、ベータ版のAI(人工知能)を使用して翻訳されており、エラーが含まれている可能性があります。このページを英語で表示するには、 こちら をクリックしてください。


概要
コールバック
OnCallInviteInvoked(tag: string,callParticipantIds: {any}):Instance
継承されたメンバー

APIリファレンス
方法
CanSendCallInviteAsync
イールド
機能: Social
SocialService:CanSendCallInviteAsync(player:Instance):boolean
パラメータ
player:Instance
戻り値
コードサンプル
SocialService:PromptPhoneBook()
local Players = game:GetService("Players")
local SocialService = game:GetService("SocialService")
local player = Players.LocalPlayer
local button = script.Parent
button.Visible = false
-- プレイヤーが呼び出しの招待を送ることができるかを確認する関数
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
イールド
機能: Social
SocialService:CanSendGameInviteAsync(
player:Instance, recipientId:User
パラメータ
player:Instance
recipientId:User
既定値: "U1.AQAAAAAAAAAAAAAAAAAAAAA"
戻り値
コードサンプル
招待を送信
local SocialService = game:GetService("SocialService")
local Players = game:GetService("Players")
local player = Players.LocalPlayer
-- プレイヤーが招待を送信できるかどうかを確認する関数
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

GetEventRsvpStatusAsync
イールド
機能: Social
SocialService:GetEventRsvpStatusAsync(eventId:string):Enum.RsvpStatus
パラメータ
eventId:string
コードサンプル
ソーシャルサービス:PromptRsvpToEventAsync()
local SocialService = game:GetService("SocialService")
local EVENT_ID = "YOUR_EVENT_ID"
local followPrompt: ProximityPrompt = script.Parent.FollowProximityPrompt
local unFollowPrompt: ProximityPrompt = script.Parent.UnfollowProximityPrompt
local function updatePrompt(rsvpStatus: Enum.RsvpStatus)
if rsvpStatus == Enum.RsvpStatus.Going then
unFollowPrompt.Enabled = true
followPrompt.Enabled = false
else
unFollowPrompt.Enabled = false
followPrompt.Enabled = true
end
end
local success, currentRsvpStatus = pcall(function()
return SocialService:GetEventRsvpStatusAsync(EVENT_ID)
end)
if not success then
-- RSVPステータスを取得できませんでした; いずれの近接プロンプトも有効にしません
warn("RSVPステータスの取得に失敗しました:", currentRsvpStatus)
return
end
print("現在のRSVPステータス:", currentRsvpStatus)
updatePrompt(currentRsvpStatus)
unFollowPrompt.Triggered:Connect(function(player)
local rsvpStatus = SocialService:PromptRsvpToEventAsync(EVENT_ID)
updatePrompt(rsvpStatus)
end)
followPrompt.Triggered:Connect(function(player)
local rsvpStatus = SocialService:PromptRsvpToEventAsync(EVENT_ID)
updatePrompt(rsvpStatus)
end)

GetExperienceEventAsync
イールド
機能: Social
SocialService:GetExperienceEventAsync(eventId:string):ExperienceEvent?
パラメータ
eventId:string
戻り値
ExperienceEvent?
コードサンプル
SocialService:GetUpcomingExperienceEventsAsync()
local SocialService = game:GetService("SocialService")
-- 次の進行中/アクティブなイベントを発見し、プレイヤーにRSVPを促します
local function promptNextUpcomingEvent()
local success, eventsOrError = pcall(function()
return SocialService:GetUpcomingExperienceEventsAsync()
end)
if not success then
warn("次のイベントの読み込みに失敗しました:", eventsOrError)
return
end
local upcomingEvents = eventsOrError
local selectedEvent
for _, event in ipairs(upcomingEvents) do
if not event.HasStarted and not event.HasEnded then
selectedEvent = event
break
end
end
if selectedEvent then
local success, result = pcall(function()
return SocialService:PromptRsvpToEventAsync(selectedEvent.Id)
end)
if not success then
warn("RSVPのプロンプトに失敗しました:", result)
end
else
warn("プロンプト可能な将来のイベントはありません。")
return
end
end
promptNextUpcomingEvent()

GetPartyAsync
イールド
機能: Social
SocialService:GetPartyAsync(partyId:string):{any}
パラメータ
partyId:string
戻り値
コードサンプル
SocialService:GetPartyAsync()
local SocialService = game:GetService("SocialService")
local Players = game:GetService("Players")
Players.PlayerAdded:Connect(function(player)
local partyId = player.PartyId
if partyId == "" then
warn("プレイヤーはパーティーに参加していません")
return
end
local success, partyData = pcall(function()
return SocialService:GetPartyAsync(partyId)
end)
if success and partyData then
for _, partyMemberData in partyData do
print(
partyMemberData.UserId,
partyMemberData.PlaceId,
partyMemberData.JobId,
partyMemberData.PrivateServerId,
partyMemberData.ReservedServerAccessCode
)
end
else
warn("パーティーデータの取得に失敗しました")
end
end)

GetPlayersByPartyId
機能: Social
SocialService:GetPlayersByPartyId(partyId:string):{Player}
パラメータ
partyId:string
戻り値
コードサンプル
SocialService:GetPlayersByPartyId()
local SocialService = game:GetService("SocialService")
local Players = game:GetService("Players")
Players.PlayerAdded:Connect(function(player)
local partyId = player.PartyId
if partyId ~= "" then
local partyPlayers: { Player } = SocialService:GetPlayersByPartyId(partyId)
for _, partyMember in partyPlayers do
print("パーティーメンバー: " .. partyMember.Name)
end
else
warn("プレイヤーはパーティーに参加していません")
end
end)
パーティ統合によるチーム再バランス
local Teams = game:GetService("Teams")
local Players = game:GetService("Players")
local SocialService = game:GetService("SocialService")
local redTeam = Instance.new("Team")
redTeam.Name = "レッドチーム"
redTeam.TeamColor = BrickColor.Red()
redTeam.AutoAssignable = false
redTeam.Parent = Teams
local blueTeam = Instance.new("Team")
blueTeam.Name = "ブルーチーム"
blueTeam.TeamColor = BrickColor.Blue()
blueTeam.AutoAssignable = false
blueTeam.Parent = Teams
local function assignPlayerToTeam(player)
local partyId = player.PartyId
if partyId == "" then
assignBalancedTeam(player)
return
end
local teams = { redTeam, blueTeam }
local matchingTeam = nil
local partyPlayers = SocialService:GetPlayersByPartyId(partyId)
for _, partyPlayer in partyPlayers do
if partyPlayer ~= player and table.find(teams, partyPlayer.Team) then
matchingTeam = partyPlayer.Team
break
end
end
if matchingTeam then
player.Team = matchingTeam
player.TeamColor = matchingTeam.TeamColor
else
assignBalancedTeam(player)
end
end
function assignBalancedTeam(player)
local redCount = #redTeam:GetPlayers()
local blueCount = #blueTeam:GetPlayers()
local chosenTeam = redCount <= blueCount and redTeam or blueTeam
player.Team = chosenTeam
player.TeamColor = chosenTeam.TeamColor
end
local function groupPlayersByParty()
local seenPartyIds = {}
local groupedPlayers = {}
for _, player in Players:GetPlayers() do
if player.PartyId == "" then
table.insert(groupedPlayers, { player })
elseif not table.find(seenPartyIds, player.PartyId) then
table.insert(seenPartyIds, player.PartyId)
local partyPlayers = SocialService:GetPlayersByPartyId(player.PartyId)
table.insert(groupedPlayers, partyPlayers)
end
end
return groupedPlayers
end
-- この関数を呼び出してチームのバランスを再調整する
local function rebalanceTeams()
local groups = groupPlayersByParty()
table.sort(groups, function(a, b)
return #a > #b
end)
for _, player in Players:GetPlayers() do
player.Team = nil
end
for _, group in groups do
local redCount = #redTeam:GetPlayers()
local blueCount = #blueTeam:GetPlayers()
local bestTeam
if redCount <= blueCount then
bestTeam = redTeam
else
bestTeam = blueTeam
end
for _, player in group do
player.Team = bestTeam
player.TeamColor = bestTeam.TeamColor
end
end
for _, player in Players:GetPlayers() do
player:LoadCharacterAsync()
end
end
Players.PlayerAdded:Connect(function(player)
assignPlayerToTeam(player)
player:LoadCharacterAsync()
player:GetPropertyChangedSignal("PartyId"):Connect(function()
if player.PartyId ~= "" then
assignPlayerToTeam(player)
end
end)
end)

GetUpcomingExperienceEventsAsync
イールド
機能: Social
SocialService:GetUpcomingExperienceEventsAsync():{ExperienceEvent}
戻り値
{ExperienceEvent}
コードサンプル
SocialService:GetUpcomingExperienceEventsAsync()
local SocialService = game:GetService("SocialService")
-- 次の進行中/アクティブなイベントを発見し、プレイヤーにRSVPを促します
local function promptNextUpcomingEvent()
local success, eventsOrError = pcall(function()
return SocialService:GetUpcomingExperienceEventsAsync()
end)
if not success then
warn("次のイベントの読み込みに失敗しました:", eventsOrError)
return
end
local upcomingEvents = eventsOrError
local selectedEvent
for _, event in ipairs(upcomingEvents) do
if not event.HasStarted and not event.HasEnded then
selectedEvent = event
break
end
end
if selectedEvent then
local success, result = pcall(function()
return SocialService:PromptRsvpToEventAsync(selectedEvent.Id)
end)
if not success then
warn("RSVPのプロンプトに失敗しました:", result)
end
else
warn("プロンプト可能な将来のイベントはありません。")
return
end
end
promptNextUpcomingEvent()

HideSelfView
機能: Social
SocialService:HideSelfView():()
戻り値
()

PromptFeedbackSubmissionAsync
イールド
機能: Social
SocialService:PromptFeedbackSubmissionAsync(options:Dictionary?):()
パラメータ
options:Dictionary?
戻り値
()
コードサンプル
SocialService:PromptFeedbackSubmissionAsync()
local SocialService = game:GetService("SocialService")
-- フィードバックを求める関数
local function promptForFeedback()
local success, errorMessage = pcall(function()
SocialService:PromptFeedbackSubmissionAsync()
end)
if success then
print("フィードバックのPromptが完了しました")
else
warn("フィードバックを求めることに失敗しました:", errorMessage)
end
end
-- プレイヤーがマイルストーンに達したときにフィードバックを求める
local function onMilestoneReached()
promptForFeedback()
end
-- 使用例: ゲームイベントに接続する
game.ReplicatedStorage.MilestoneReached.OnClientEvent:Connect(onMilestoneReached)
SocialService:PromptFeedbackSubmissionAsync() — プレイヤーサポート
local SocialService = game:GetService("SocialService")
local function promptPlayerSupport()
local success, errorMessage = pcall(function()
SocialService:PromptFeedbackSubmissionAsync({
FeedbackType = Enum.FeedbackType.PlayerSupport,
})
end)
if success then
print("プレイヤーサポートのプロンプトが完了しました")
else
warn("プレイヤーサポートのプロンプトに失敗しました:", errorMessage)
end
end
-- 使用例: ScreenGui のヘルプボタンに接続
local helpButton = script.Parent:WaitForChild("HelpButton")
helpButton.Activated:Connect(function()
task.spawn(promptPlayerSupport)
end)

PromptGameInvite
機能: Social
SocialService:PromptGameInvite(
player:Instance, experienceInviteOptions:Instance
):()
パラメータ
player:Instance
experienceInviteOptions:Instance
既定値: "nil"
戻り値
()
コードサンプル
招待を送信
local SocialService = game:GetService("SocialService")
local Players = game:GetService("Players")
local player = Players.LocalPlayer
-- プレイヤーが招待を送信できるかどうかを確認する関数
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

PromptLinkSharing
非推奨

PromptLinkSharingAsync
イールド
機能: Social
SocialService:PromptLinkSharingAsync(
player:Player, options:Dictionary
パラメータ
player:Player
options:Dictionary
既定値: "nil"
戻り値

PromptPhoneBook
機能: Social
SocialService:PromptPhoneBook(
player:Instance, tag:string
):()
パラメータ
player:Instance
tag:string
戻り値
()
コードサンプル
SocialService:PromptPhoneBook()
local Players = game:GetService("Players")
local SocialService = game:GetService("SocialService")
local player = Players.LocalPlayer
local button = script.Parent
button.Visible = false
-- プレイヤーが呼び出しの招待を送ることができるかを確認する関数
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

PromptRsvpToEventAsync
イールド
機能: Social
SocialService:PromptRsvpToEventAsync(eventId:string):Enum.RsvpStatus
パラメータ
eventId:string
コードサンプル
ソーシャルサービス:PromptRsvpToEventAsync()
local SocialService = game:GetService("SocialService")
local EVENT_ID = "YOUR_EVENT_ID"
local followPrompt: ProximityPrompt = script.Parent.FollowProximityPrompt
local unFollowPrompt: ProximityPrompt = script.Parent.UnfollowProximityPrompt
local function updatePrompt(rsvpStatus: Enum.RsvpStatus)
if rsvpStatus == Enum.RsvpStatus.Going then
unFollowPrompt.Enabled = true
followPrompt.Enabled = false
else
unFollowPrompt.Enabled = false
followPrompt.Enabled = true
end
end
local success, currentRsvpStatus = pcall(function()
return SocialService:GetEventRsvpStatusAsync(EVENT_ID)
end)
if not success then
-- RSVPステータスを取得できませんでした; いずれの近接プロンプトも有効にしません
warn("RSVPステータスの取得に失敗しました:", currentRsvpStatus)
return
end
print("現在のRSVPステータス:", currentRsvpStatus)
updatePrompt(currentRsvpStatus)
unFollowPrompt.Triggered:Connect(function(player)
local rsvpStatus = SocialService:PromptRsvpToEventAsync(EVENT_ID)
updatePrompt(rsvpStatus)
end)
followPrompt.Triggered:Connect(function(player)
local rsvpStatus = SocialService:PromptRsvpToEventAsync(EVENT_ID)
updatePrompt(rsvpStatus)
end)

ShowSelfView
機能: Social
SocialService:ShowSelfView(selfViewPosition:Enum.SelfViewPosition):()
パラメータ
selfViewPosition:Enum.SelfViewPosition
既定値: "LastPosition"
戻り値
()

イベント
CallInviteStateChanged
機能: Social
SocialService.CallInviteStateChanged(
player:Instance, inviteState:Enum.InviteState
パラメータ
player:Instance
inviteState:Enum.InviteState
コードサンプル
ソーシャルサービス.コールインバイトステート変更
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
機能: Social
SocialService.GameInvitePromptClosed(
player:Instance, recipientIds:{any}
パラメータ
player:Instance
recipientIds:{any}

PhoneBookPromptClosed
機能: Social
SocialService.PhoneBookPromptClosed(player:Instance):RBXScriptSignal
パラメータ
player:Instance

ShareSheetClosed
機能: Social
SocialService.ShareSheetClosed(player:Player):RBXScriptSignal
パラメータ
player:Player

コールバック
OnCallInviteInvoked
機能: Social
SocialService.OnCallInviteInvoked(
tag:string, callParticipantIds:{any}
パラメータ
tag:string
callParticipantIds:{any}
戻り値
コードサンプル
ソーシャルサービス.OnCallInviteInvoked
local SocialService = game:GetService("SocialService")
local TeleportService = game:GetService("TeleportService")
SocialService.OnCallInviteInvoked = function()
local placeId = 0123456789 -- これはコール参加者を落とすための対象場所の場所IDです
local accessCode = TeleportService:ReserveServerAsync(placeId)
return { ReservedServerAccessCode = accessCode, PlaceId = placeId }
end

©2026 Roblox Corporation。Roblox(ロブロックス)、RobloxロゴおよびPowering Imaginationは、米国並びにその他の国における登録商標および非登録商標です。