Basic Usage
Here's an example of how to use the Giftoin Module to send points to a player when they join the game.
Server Script Example
Place this script in ServerScriptService
:
Explanation
We start by requiring the necessary modules from the GiftoinModule.
We define configuration variables for the campaign ID, point ID, and the amount of points to award when joining. You should replace these with your actual values (from you Giftoin Dashboard website).
The
onPlayerJoin
function is defined to send points to a player when they join. It usesGiftoinApi.sendPoint()
with the following parameters:robloxId
: The player's Roblox User ID as a stringcampaignId
: The ID of your campaignpointId
: The ID of the point type you're awardingquantity
: The number of points to award
We connect the
onPlayerJoin
function to thePlayerAdded
event, so it runs whenever a new player joins the game.We also set up an event handler for the
ClaimGiftoinEvent
. This demonstrates how to use thesendPoint
function in a different scenario, such as awarding daily rewards that will be explained in more detail in the Additional Example / Use-Cases section.
Important Notes
Make sure to replace
"your_campaign_id_here"
and"your_point_id_here"
with your actual campaign and point IDs.The
robloxId
is obtained from the player'sUserId
and converted to a string, as required by thesendPoint
function.Error handling is implemented to log any issues with sending points.
This example assumes that the
sendPoint
function returns a success boolean and a result. Adjust the error handling if the function behaves differently.
Last updated