เรียนรู้
Engine Class
SocialService
ไม่สามารถสร้าง
บริการ
ไม่ซ้ำ

*เนื้อหานี้แปลโดยใช้ AI (เวอร์ชัน Beta) และอาจมีข้อผิดพลาด หากต้องการดูหน้านี้เป็นภาษาอังกฤษ ให้คลิกที่นี่


สรุป
Callbacks
OnCallInviteInvoked(tag: string,callParticipantIds: {any}):Instance
สมาชิกที่ได้รับทอด

เอกสารอ้างอิงเกี่ยวกับ API
วิธีการ
CanSendCallInviteAsync
ผลตอบแทน
ความสามารถ: Social
SocialService:CanSendCallInviteAsync(player:Instance):boolean
พารามิเตอร์
player:Instance
ส่งค่ากลับ
ตัวอย่างโค้ด
บริการสังคม: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
ส่งค่ากลับ
ตัวอย่างโค้ด
SocialService: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
-- ไม่สามารถดึงสถานะการตอบรับเข้าร่วมกิจกรรมได้; ไม่ให้เปิดตัวเสนอใด ๆ
warn("ล้มเหลวในการดึงสถานะการตอบรับเข้าร่วมกิจกรรม:", currentRsvpStatus)
return
end
print("CurrentRsvpStatus:", 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")
-- ค้นหากิจกรรมถัดไปที่กำลังจะมาถึง/กำลังดำเนินการและเชิญชวนผู้เล่นให้ตอบรับเข้าร่วม
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("ล้มเหลวในการเชิญชวนให้ตอบรับเข้าร่วม:", 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")
-- ค้นหากิจกรรมถัดไปที่กำลังจะมาถึง/กำลังดำเนินการและเชิญชวนผู้เล่นให้ตอบรับเข้าร่วม
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("ล้มเหลวในการเชิญชวนให้ตอบรับเข้าร่วม:", 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("การเรียกความคิดเห็นเสร็จสมบูรณ์")
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
ส่งค่ากลับ
()
ตัวอย่างโค้ด
บริการสังคม: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
ส่งค่ากลับ
ตัวอย่างโค้ด
SocialService: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
-- ไม่สามารถดึงสถานะการตอบรับเข้าร่วมกิจกรรมได้; ไม่ให้เปิดตัวเสนอใด ๆ
warn("ล้มเหลวในการดึงสถานะการตอบรับเข้าร่วมกิจกรรม:", currentRsvpStatus)
return
end
print("CurrentRsvpStatus:", 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
ตัวอย่างโค้ด
SocialService.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
ความสามารถ: 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

Callbacks
OnCallInviteInvoked
ความสามารถ: Social
SocialService.OnCallInviteInvoked(
tag:string, callParticipantIds:{any}
พารามิเตอร์
tag:string
callParticipantIds:{any}
ส่งค่ากลับ
ตัวอย่างโค้ด
SocialService.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 เป็นส่วนหนึ่งของเครื่องหมายการค้าที่จดทะเบียน และไม่ได้จดทะเบียนของเราในสหรัฐฯ และประเทศอื่นๆ