I read the documentation and asked AI but I’m still not sure how they work, I have the following questions down below.
How they are sent, do I have to manually send them to the user or roblox decides when to send them?
Do they get sent even if there are no servers?
How do I choose the users to who to send?
local ServerScriptService = game:GetService("ServerScriptService")
local OCUserNotification = require(ServerScriptService.OpenCloud.V2.UserNotification)
local recipientPlayerID = 505306092
-- In the payload, "messageId" is the value of the notification asset ID
local userNotification = {
payload = {
messageId = "5dd7024b-68e3-ac4d-8232-4217f86ca244",
type = "MOMENT"
}
}
local result = OCUserNotification.createUserNotification(recipientPlayerID, userNotification)
if result.statusCode ~= 200 then
print(result.statusCode)
print(result.error.code)
print(result.error.message)
end
I kinda don’t understand this piece of code, does the server have to join the game to get the notification?
They’re sent on an Open Cloud endpoint. You manually create notifications and Roblox can throttle/block any for spam. They may be delayed but they aren’t scheduled with any reasonable precision.
Notifications don’t care about game servers. This example and the package for it inherently have to run on an active game server. The endpoint is accessible to external tools.
Collect IDs of users who enable notifications when prompted, then fire the endpoint for each ID that the notification is applicable for.
No? I don’t know what you mean by “servers getting a notification”. There is only a reliance on game servers if you’re using that example code because it references the datamodel of a running game.
Yeah, that’d work. Besides global promotional notifications, handling this in game lets you bind to player actions much easier. For example, a player’s offline base being raided can notify them.