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

Dev Products are not working like they should?

Asked by 7 years ago
local MarketplaceService = game:GetService('MarketplaceService')
local adspace = (i put the id here)

local WebhookId     = "i put the id here"
local WebhookToken  = "i put the id here"
server = nil 
service = nil
local Http = game:GetService("HttpService")
local webHook = require(script.Parent.WebhookAPI)
local Discord_Webhook = webHook.new(WebhookId,WebhookToken) 


MarketplaceService.ProcessReceipt = function(receiptInfo)
    for i, player in ipairs(game.Players:GetChildren())  do
        if player.userId == receiptInfo.PlayerId then
            if receiptInfo.ProductId == adspace then
                local newAd = Instance.new("IntValue", game.ServerScriptService.PendingAdvertisements)
                player.CharData.exp.Value = player.CharData.exp.Value + 60
                local exp = player.CharData.exp.Value
                local totalexp = player.CharData.totalexp.Value
                local level = player.CharData.level.Value
                if exp > totalexp then
                    exp = exp - 500
                    level = level + 1
                    Discord_Webhook:post{content = player.Name .." has reached Level ".. level .."!"}
                end
                game.ReplicatedStorage.UpdateProfile:FireClient(player, exp, totalexp, level)
                wait(1)
                newAd.Name = game.ServerScriptService.PendingAdvertisements:FindFirstChild(player.Name).Value
                newAd.Parent = game.ServerScriptService.Advertisements
                print('passed final loop')
                game.ReplicatedStorage.PurchaseSuccessful:FireClient(player)
                Discord_Webhook:post{content = player.Name .." has spent 100R$ on an Advertisement!"}
            end
        end
    end

    return Enum.ProductPurchaseDecision.PurchaseGranted
end

-------- SO

Whenever, the "level up" works, but whenever someone Purchases the Dev Product, it says "Player (name) has reached level 1" instead of "has purchased an ad"

Why? Can someone fix for me possibly?

0
Anyone? Obdormition 15 — 7y

Answer this question