Hello my name is Jar and I wanted to make subscriptions for my game. So I started making a module but then I kept going and now it has around 20 functions! If u use this a credit in the description would be appreciated!
Set the value path to your stat folder name, standard is “Stats”
If somethings bugs make sure to send me a message as this is the first version make sure to test your things!!
Discord: Jar_Dev#0001
Functions:
Subscriptions
IsSubscribed
This function returns true or false depending if the subscription is still active
function SS.IsSubscribed(plr, endtime)
if os.time() > endtime then
return false
else
return true
end
end
Subscibe
This can be used to calculate the UNIX EPOCH time, you need to put in the player the amount of time and the timenotation
function SS.Subscribe(plr, timeamount ,notation)
-- Converting timeamount to seconds --
-- if notation = seconds then timeamount is already in seconds --
if notation == "Minutes" then
timeamount *= 60
elseif notation == "Hours" then
timeamount *= 3600
elseif notation == "Days" then
timeamount *= 86400
elseif notation == "Weeks" then
timeamount *= 604800
elseif notation == "Months" then
timeamount *= 2629800
end
return os.time() + timeamount
end
Gift
Use this to give a player a boolvalue or numbervalue, this can be used for for example gamepass gifting. Just make a BoolValue call it after the gamepass and call the function with the player who is gifting, the player who is being gifted to, the stat name, if it is a numbervalue put the amount
function SS.Gift(plr,target,stat,amount)
--[[
How to use: plr is the player who is gifting target is the player who is being gifted to stat is the name of the stat that is being gifted
yourvariable.Gift(Player1,Player2,"VIP")
yourvariable.Gift(Player1,Player2,"Money",100)
READ!: if the stat being gifted is a gamepass then amount is not needed if it is a NumberValue then amount is the amount being gifted
if a gamepass is being gifted make sure you have a BoolValue named after the gamepass being gifted
]]
if game.Players:FindFirstChild(target) then
if game.Players[target][path][stat]:IsA("NumberValue") then
game.Players[target][path][stat].Value = tonumber(amount)
elseif game.Players[target][path][stat]:IsA("BoolValue") then
game.Players[target][path][stat].Value = true
else
return false
end
return true
else
return false
end
end
Boosters
BoosterActive
returns either true or false depending on if the booster is still active
function SS.BoosterActive(plr,boosttype) -- For example x2Coins
if os.time() > plr[path][boosttype].Value then
return false
else
return true
end
end
GetTimeRemaining
returns a integer value of how much time is left on the booster
function SS.GetTimeRemaining(plr,boosttype)
if SS.BoosterActive(plr,boosttype) then
return plr[path][boosttype].Value - os.time()
else
return false
end
end
SetBoosterTime
Used to calculate the UNIX EPOCH time returns your input in seconds so you can use boosters with os.time()
function SS.SetBoosterTime(plr,boostertype,timeamount,notation)
-- Converting timeamount to seconds --
if notation == "Minutes" then
timeamount *= 60
elseif notation == "Hours" then
timeamount *= 3600
elseif notation == "Days" then
timeamount *= 86400
elseif notation == "Weeks" then
timeamount *= 604800
elseif notation == "Months" then
timeamount *= 2629800
end
return os.time() + timeamount
end
Other
Prompting
PromptGamepass:
function SS.PromptGamepass(plr,id)
return MS:PromptGamePassPurchase(plr,id)
end
PromptPremium:
function SS.PromptPremium(plr)
return MS:PromptPremiumPurchase(plr)
end
PromptAsset:
function SS.PromptAsset(plr,id)
MS:PromptPurchase(plr,id)
end
PromptBundle:
function SS.PromptBundle(plr,id)
return MS:PromptBundlePurchase(plr,id)
end
PromptProduct:
function SS.PromptProduct(plr,id)
return MS:PromptProductPurchase(plr,id)
end
OwnsGP:
Returns true or false depending if the user owns the gamepass or has been gifted/boolvalue is true
function SS.OwnsGP(plr,id,gpname)
if MS:UserOwnsGamePassAsync(plr,id) or plr[path][gpname].Value then
return true
else
return false
end
end
OwnsAsset:
returns true or false depending if the user owns the asset
function SS.OwnsAsset(plr,assetid)
return MS:PlayerOwnsAsset(plr,assetid)
end
IsPremium:
returns true or false if the user is a subscriber of premium
function SS.IsPremium(plr)
if plr.MembershipType == Enum.MembershipType.Premium then
return true
else
return false
end
end
GetProductInfo:
function SS.GetProductInfo(id,infotype)
return MS:GetProductInfo(id,infotype)
end
GetDeveloperProductsAsync:
function SS.GetDeveloperProductsAsync()
return MS:GetDeveloperProductsAsync()
end
IsPrivateServer:
returns true or false depending if the serevr is a private server
function SS.IsPrivateServer()
if game.PrivateServerOwnerId ~= 0 then
return true
else
return false
end
end
GetDate:
returns the date like 10/6/98
function SS.GetDate(num)
return os.date("%x",num)
end
TimeConvert:
returns the numbervalue in 10:8:16 which means 10 hours 8 minutes 16 seconds
function SS.TimeConvert(num)
local txt = ""
local days = math.floor(num/86400)
num = math.fmod(num, 86400)
local hours = math.floor(num/3600)
num = math.fmod(num, 3600)
local minutes = math.floor(num/60)
num = math.fmod(num, 60)
local seconds = math.floor(num)
if days > 0 then
txt = txt .. days .. ":"
txt = txt .. math.floor(hours/10) .. math.fmod(hours, 10) .. ":"
txt = txt .. math.floor(minutes/10) .. math.fmod(minutes, 10) .. ":"
txt = txt .. math.floor(seconds/10) .. math.fmod(seconds, 10) .. "."
elseif hours > 0 then
txt = txt .. hours .. ":"
txt = txt .. math.floor(minutes/10) .. math.fmod(minutes, 10) .. ":"
txt = txt .. math.floor(seconds/10) .. math.fmod(seconds, 10) .. "."
elseif minutes > 0 then
txt = txt .. minutes .. ":"
txt = txt .. math.floor(seconds/10) .. math.fmod(seconds, 10) .. ""
else
txt = txt .. seconds .. ""
end
return txt
end
Roadmap:
V1.1 will feature starterpacks and some optimization
V1.2 will feature passes/battle passes
V1.3 give me suggestions