Subscription monthly

Hello!

I am looking to make a monthly subscription proccess for my game! I was wondering if there was any way to do this.
I have a theory but I do not know how to make it: When you buy the subscription it logs the date (ex 5/07/2021), then each time you join the game it checks the date seeing if it is now 6/07/2021. (or any month pair like that) I also saw os.date(%m) returns month as in 06

Is this the way I should do it, or is there another way?

1 Like

I’m not a very experienced scripter, but that sounds fine to me. Here’s how I would do it:
First, of course, you have to buy the gamepass.
When the gamepass is bought, the script stores the date in a Data Stores | Roblox Creator Documentation
Each time the player joins (You can use the PlayerAdded event), it checks to see if it is 1 month past the original.
If it is, then the game does whatever you want it to do.
(Essentially the same thing you said)

If you’re not sure how to script it, you could look on the dev hub to learn how to use os.time and so on.

Edit: You might have found this already but here is the dev hub post on os.time: os | Roblox Creator Documentation

    if PlayerDat.Server ~= nil and PlayerDat.Server.StartDate ~= nil then
        local date = os.date("%x")
        local function removezeros(str)
            return str:gsub("0","")
        end
        local finaldate = tostring(removezeros(date))
        local finaldatevalues = finaldate:split("/")
        local finaldatemonth = finaldatevalues[1]
        local finaldateday = finaldatevalues[2]
        local finaldateyear = finaldatevalues[3]
        
        local startdatevalues = PlayerDat.Server.StartDate:Split("/")
        local startdatemonth = startdatevalues[1]
        local startdateday = startdatevalues[2]
        local startdateyear = startdatevalues[3]

        if startdateday == finaldateday and startdateyear == finaldateyear then -- what if its the last month and then year changes
            if tonumber(startdatemonth) + 1 == tonumber(startdatemonth) then
                -- Their Subscription is over
            end
        end
    end

In the comments I put what if its like 11/7/2021 and you buy the subscription, how would I check for it on 12/7/2022, because in the code I just showed i need to check for if day and year the same