Point Reward
Server Script Example
-- Require the necessary modules
local GiftoinApi = require(game.ReplicatedStorage.GiftoinModule.API)
local GiftoinUtils = require(game.ReplicatedStorage.GiftoinModule.Utils)
local GiftoinEvents = require(game.ReplicatedStorage.GiftoinModule.Events)
-- Configuration (replace with your actual values)
local CAMPAIGN_ID = "your_campaign_id_here"
local POINT_ID = "your_point_id_here"
local JOIN_REWARD_AMOUNT = 100
-- Function to send points when a player joins
local function onPlayerJoin(player)
local robloxId = tostring(player.UserId)
-- Send points to the player
local success, result = GiftoinApi.sendPoint(robloxId, CAMPAIGN_ID, POINT_ID, JOIN_REWARD_AMOUNT)
if success then
print(player.Name .. " was awarded " .. JOIN_REWARD_AMOUNT .. " points for joining!")
else
warn("Failed to send points to " .. player.Name .. ". Error: " .. tostring(result))
end
end
-- Connect the function to the PlayerAdded event
game.Players.PlayerAdded:Connect(onPlayerJoin)
-- Set up the ClaimGiftoin event handler
local claimGiftoinEvent = game.ReplicatedStorage.GiftoinModule.ClaimGiftoinEvent
claimGiftoinEvent.OnServerEvent:Connect(function(player)
-- Example of using sendPoint for a different scenario
local success, result = GiftoinApi.sendPoint(tostring(player.UserId), CAMPAIGN_ID, "daily_reward", 50)
if success then
print(player.Name .. " claimed their daily reward of 50 points!")
else
warn("Failed to send daily reward points to " .. player.Name .. ". Error: " .. tostring(result))
end
end)