#Developer product not working

26 messages · Page 1 of 1 (latest)

vital flame
#

For some reason my developer product script isnt working

#

So I am making a developer product shop that when the player buys it, it gives them money (leaderstat)

#

But my leaderstats aren't set the normal way, they use Datastore2

#

Here is the current code:

local DataStore2 = require(game.ServerScriptService.Server.MainModule)
local DataStoreService = game:GetService("DataStoreService")

local currencyName = "money"

local PreviousPurhcases = DataStoreService:GetDataStore("PreviousPurchases")
local FIVE_THOUSAND = 1568934660

MarketplaceService.ProcessReceipt = function(receipt)
    
    local ID = receipt.PlayerId.."-"..receipt.PurchaseId
    local sucess = nil
    pcall (function()
        sucess = PreviousPurhcases:GetAsync(ID)
    end)

    if sucess then
        return Enum.ProductPurchaseDecision.PurchaseGranted
    end

    local player = game.Players:GetPlayerByUserId(receipt.PlayerId)

    if not player then

        return Enum.ProductPurchaseDecision.NotProcessedYet

    else        

        if receipt.ProductId == FIVE_THOUSAND then

            local player = game.Players:GetPlayerFromCharacter()
            if player then
                local coinsStore = DataStore2("money",player)
                coinsStore:Increment(5000)
            end
            pcall(function()
                PreviousPurhcases:SetAsync(ID,true)
            end)
            return Enum.ProductPurchaseDecision.PurchaseGranted
        end
    end
end```
#

And for example, for this other script it did work:

    
    local player = game.Players:GetPlayerFromCharacter(hit.Parent)
    
    if player then
        local coinsStore = DataStore2("money",player)
        coinsStore:Increment(15)
    end
    
end)```
rancid steeple
#

I wanna help but I am already boutta sleep a

#

I also use DataStore2 for my currency as well as developer products

vital flame
#

Cool

#

So why isn't it working? Because I asked ChatGPT why it isn't working and it just says that it should be working and it doesn't detect any errors

rancid steeple
#

But from what I see you can remove the pcalls since increment causes the datastore to save automatically

#

Yk what

#

I‘ll get on rq and see how mine is like

vital flame
#

I remove pcalls and it still doesn't work

warped thistleBOT
#

studio** You are now Level 2! **studio

rancid steeple
#

I know, hold up

vital flame
#

Alright thank you

rancid steeple
#

that's the one I wrote and it works perfectly fine

#

You can use it too!

#

Do you understand what to replace?

vital flame
#

Yup

#

Ill try it thanks

rancid steeple
#

I have multiple dev products that's why I use so much id's

#

ywhope

vital flame
#

Wow it works

#

Thank you so much ❤️

rancid steeple
#

You're welcome :D