How would I go about making a referral system?

As the title says, how would I go about making a referral system that doesn’t involve using SocialService. This is the idea I currently have:

1: Use the Players’ ID as the referral code.
2: Using DatastoreStoreService to store the ID of the value they have selected as who referred them and then there would be another DataStore to store the amount of referrals YOU as the player have gotten
3: Adding a Prompt to ensure that the player(the player who is referring you) is the correct player and ensuring that you can’t input yourself as the person who referred you.
4: For each player, a table is stored(inside datastore) with example data:

-- Players who you have referred
local referral_list = {
    [1] = [234234234, true], -- [Player_ID, wasRewardRedeemed] 
    [2] = [9548954, false],
}

Explanation:
each player will have a table named “referral_list” under each user which will contain the values of each player:
Their ID and whether or not if the referral reward has been redeemed(like have we actually NOTIFIED the player that they have referred player B and gave the rewards for it)

I just need some insight on this on anyone who has made something like this before and if it’s a good start and what improvements or dangers I need to look out for(such as 2 players redeeming the same referral code at the same time).

I’ll be probably be using UpdateAsync() and and GetAsync() methods.

To me your idea sounds pretty solid.

However, I don’t quite understand what you mean in the example data. I first had the impression you were gonna have two data stores.

DataStore 1 would contain what referral code a user had used.
DataStore 2 would contain a list of all referral codes and (who/amount) had used them.

Would you be able to explain a bit more what the example data is supposed to mean?

Essentially, when you put in the code of the user who referred you, for example my Roblox User ID is 794444736. It would get my data from the datastore using my ID(794444736) as the key. Inside the data would contain the table i.e the referral_list(example data)

local referral_list = {
    [1] = [234234234, true], -- [Player_ID, wasRewardRedeemed] 
    [2] = [9548954, false],
}

Essentially, the table will contain the IDs of the people you referred along with a boolean value stating whether or not you have redeemed the rewards from the people you referred.

I’m using ProfileService so that’s why I’m not giving the rewards when the player is offline. Essentially those boolean values are waiting to be set to true when the player who referred others comes online.

Reason I was asking was because I was wondering if anyone has had experience this before and if there’s any conflicts with UpdateAsync, like 2 players redeeming the same code at the same time or if there’s anything else I should take into consideration when implementing this such as datastore limits or whatever.

I think this should be fine. If you for some reason would run into issues for the size of [Player_ID, wasRedeemed] you can always change to save #redeemedReferrals and #totalReferrals.

1 Like

Yeah, seems plausible.

Is there any way to check if the amount of data(in MB) store is about to exceed a certain percentage?(Like 95%). If that’s the case then I can make the first value of the datastore contain, like you said, #redeemedReferrals and #totalReferrals

Though now that you mention it, #redeemedReverrals and #totalReferrals could be much simpler.

In general, I’m surprised I haven’t seen that many Roblox games with this feature. I could be wrong.

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