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

Problem with script that is supposed to increase a leaderstat by 1,000. How do I fix it?

Asked by 6 years ago

This script is a dev product that when bought is supposed to add 1,000 gold to the person's LeaderStats. However, no matter what I do I can't seem to get it to work. I'm pretty sure the problem is in line 22. There should be something to identify a certain player. Normally I would just put LocalPlayer but since that only works in local scripts I can't. If you need any more info on the problem post a comment on what you need to know. That is all.

-Full script

game.StarterGui.ResetPlayerGuiOnSpawn = false
old_fog = game.Lighting.FogStart
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 == 92719865 then
        local Money = game.players.leaderstats.Gold
                Money.Value = Money.Value + 1000
            end
0
ProcessReceipt is deprecated. PyccknnXakep 1225 — 6y
0
ProcessReceipt is deprecated, use the other events and functions. User#18043 95 — 6y

Answer this question