Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Why DevProduct Script don't add players money?

Asked by 6 years ago

Hello, i have problem with DevProduct Script and Gui. Sometimes it'll add money to player, but sometimes don't and i don't want to let player waste R$..

Here is script:

game.StarterGui.ResetPlayerGuiOnSpawn = false

local MarketplaceService = game:GetService("MarketplaceService")

function getPlayerFromId(id)
    for i,v in pairs(game.Players:GetChildren()) do
        if v.userId == id then
            return v
        end
    end
    return nil
end

MarketplaceService.ProcessReceipt = function(receiptInfo)
    local productId = receiptInfo.ProductId
    local playerId = receiptInfo.PlayerId
    local player = getPlayerFromId(playerId)
    local productName 
    if productId == 52142263 then
        productName = "2,000$"
        local cashmoney = game.ServerStorage.PlayerMoney:FindFirstChild(player.Name)
        game.ReplicatedStorage.MasterKey:FireClient(player,"PurchaseConfirm")
        if cashmoney then
            cashmoney.Value = cashmoney.Value + 2000
        end
    elseif productId == 52142300 then
        productName = "10,000$"
        local cashmoney = game.ServerStorage.PlayerMoney:FindFirstChild(player.Name)
        game.ReplicatedStorage.MasterKey:FireClient(player,"PurchaseConfirm")
        if cashmoney then
            cashmoney.Value = cashmoney.Value + 10000
        end
    elseif productId == 52142339 then
        productName = "25,000$"
        local cashmoney = game.ServerStorage.PlayerMoney:FindFirstChild(player.Name)
        game.ReplicatedStorage.MasterKey:FireClient(player,"PurchaseConfirm")
        if cashmoney then
            cashmoney.Value = cashmoney.Value + 25000
        end
    elseif productId == 127357125 then
        productName = "50,000$"
        local cashmoney = game.ServerStorage.PlayerMoney:FindFirstChild(player.Name)
        game.ReplicatedStorage.MasterKey:FireClient(player,"PurchaseConfirm")
        if cashmoney then
            cashmoney.Value = cashmoney.Value + 50000
        end
    elseif productId == 52142395 then
        productName = "100,000$"
        local cashmoney = game.ServerStorage.PlayerMoney:FindFirstChild(player.Name)
        game.ReplicatedStorage.MasterKey:FireClient(player,"PurchaseConfirm")
        if cashmoney then
            cashmoney.Value = cashmoney.Value + 100000
        end
    elseif productId == 127357286 then
        productName = "200,000$"
        local cashmoney = game.ServerStorage.PlayerMoney:FindFirstChild(player.Name)
        game.ReplicatedStorage.MasterKey:FireClient(player,"PurchaseConfirm")
        if cashmoney then
            cashmoney.Value = cashmoney.Value + 200000
        end
    end
    local message = Instance.new("Hint",workspace)
    message.Text = player.Name.." purchased "..productName.."!"
    coroutine.resume(coroutine.create(function()
        wait(2)
        message:destroy()
    end))

    return Enum.ProductPurchaseDecision.PurchaseGranted     
end

After buying one of these devproducts, i see in dev console something like this: https://gyazo.com/0a2b5e071d252c398828a14622261257 I don't know what does that mean. Is it problem with DataStore or something ?

0
You're throttling your DataStore! However there is no DataStore visible in this script. Check your other scripts. Crazycat4360 115 — 6y
0
Well, i have datastore in different script, but how to fix that? karolus1 8 — 6y

Answer this question