When I am creating Dev Products for cash and I never use these, however, when should I use them?
I thought a Dev Products whole purpose is to allow players to continuously purchase a single item, and those two stop them from purchasing it.
Consider using PurchaseGranted on a cash increment script, I am pretty sure once you buy it once you cannot buy it again for the server, I may be wrong though.
So if anyone could give me some examples of their uses that would be great!
They are basically gamepasses, but you can always buy them again. In the same or new server, it doesn’t matter. BUT, they don’t save from server or character death unless its like 100+ cash.
That’s not true, you can buy an item multiple times if it returns PurchaseGranted. Also those enums are used in case the purchase “reward” fails to be given to the player, example:
local Success, Error = pcall(function()
player.Cash += 100
end)
if Success then
return Enum.ProductPurchaseDecision.PurchaseGranted
else
return Enum.ProductPurchaseDecision.NotProcessedYet --this will try to reward the dev product again, if the player rejoins
end
I use PromptPurchaseProductFinished , although this script is for donations, it adds a value to the user, so implementing it to give cash would not be a challenge.
local Ids = {['1235639505']=1,['1235272685']=5,['1235272751']=10,['1235272801']=50,['1235272904']=100,['1235272955']=500,['1235273018']=1000,['1235639725']=10000}
local DDS = game:GetService("DataStoreService")
local MPS = game:GetService("MarketplaceService")
local Plrs = game:GetService("Players")
local Gcol = Color3.fromRGB(239, 184, 56)
local Scol = Color3.fromRGB(198, 198, 198)
local Bcol = Color3.fromRGB(195, 97, 0)
local Ncol = Color3.fromRGB(255,255,255)
local function RemoveSK(s:string)
if string.sub(s,1,1) == 'd' then
return string.sub(s,2,#s)
else
return s
end
end
local DonationODS = DDS:GetOrderedDataStore('Donations')
local DonBar = game:GetService("ServerStorage").Storage.GUI.DonBar
local DonB = game.Workspace.DonateB
local LG = DonB.SurfaceGui.LB.LBP
local function RefreshLB()
local Dt = DonationODS:GetSortedAsync(false,10,0,math.huge)
local CPage = Dt:GetCurrentPage()
for rank, inf in pairs(CPage) do
task.wait()
local K = inf.key
local Vl = inf.value
local NF = DonBar:Clone()
NF.Parent = LG
NF.Position = UDim2.fromScale(0,0+(0.1*(rank-1)))
repeat
task.wait()
local suc, err = pcall(function()
NF.Title.Text = Plrs:GetPlayerByUserId(RemoveSK(K)).Name
NF.Val.Text = Vl
end)
until suc
local V = NF.Val
local T = NF.Title
if rank == 1 then
V.TextColor3 = Gcol
T.TextColor3 = Gcol
elseif rank == 2 then
V.TextColor3 = Scol
T.TextColor3 = Scol
elseif rank == 3 then
V.TextColor3 = Bcol
T.TextColor3 = Bcol
elseif rank < 3 then
V.TextColor3 = Ncol
T.TextColor3 = Ncol
end
end
end
MPS.PromptProductPurchaseFinished:Connect(function(User,Product,IsBought)
if IsBought then
local Val = Ids[tostring(Product)]
if Val then
local D = DonationODS:GetAsync(User)
if not D then D = 0 end
local AVl = D + Val
DonationODS:SetAsync(User,AVl)
end
end
end)
local function LoopRef()
while true do
LG:ClearAllChildren()
RefreshLB()
task.wait(20)
end
end
coroutine.wrap(LoopRef)()
I haven’t experienced with NotProcessedYet and PurchaseGranted so I do not know much about them.
All I do know is that PromptPurchaseProductFinished fires when a user buys a developer product.