Feedback on "SocialService"

In the section PromptRsvpToEventAsync modify the code

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
	-- Could not retrieve RSVP status; don't enable either proximity prompt
	warn("Failed to get RSVP status:", 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)

Add a verification if player is following the event or not

if selectedEvent.UserRsvpStatus == Enum.RsvpStatus.NotGoing then
			local success, result = pcall(function()
				return SocialService:PromptRsvpToEventAsync(selectedEvent.Id)
			end)
			if not success then
				warn("RSVP prompt failed:", result)
			end
		else
			warn("Player is following the event")
		end

Affected URL: https://create.roblox.com/docs/reference/engine/classes/SocialService#PromptRsvpToEventAsync

Hey there!

It seems like you’re new to the DevForum.
When pasting code, we suggest you do so in a code block
To start or end a code block, type 3 backquotes (```)

Example:

print("Hello World!")

I am not affiliated with Roblox or @DevForumModerators

2 Likes

I posted it from create.roblox.com I had completely forgotten that I needed to include backquotes, ty :heart:

Hello @cebar2002.

Thanks for your feedback request!

I’ve taken a look at your suggestion and appreciate the extra checks to verify RSVP status and to reprompt if the player RSVP status is set to Not Going.

After chatting with the team, we won’t be making this addition to the code sample at this time so we can prioritize keeping code samples concise and specific to the functions they are describing.

If you had some issues with any of the code readability, I can reach out to the original author to see if we can clarify anything, either in the code sample or the API docs.

Thanks again for reaching out! Have a great rest of your day,
naahchos

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.