Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

(ANSWERD)How do i make this DevProduct Give What They Paid For?

Ive Tried To make This Work But Im Unsure Whats Wrong.

Script for serverscriptservice

local MPS = game:GetService("MarketplaceService")


MPS.ProcessReceipt = function(receiptInfo)
	if receiptInfo.ProductId == 985697300 then
		local player = game.Players:GetPlayerByUserId(receiptInfo.Playerid)
		player.leaderstats.Life.Value = player.leaderstats.Life.Value * 2
		return Enum.ProductPurchaseDecision.PurchaseGranted
	end
end

Script For StarterGUI

MPS = game:GetService("MarketplaceService")
id = 985697300
local player = game.Players.LocalPlayer

script.Parent.MouseButton1Click:connect(function()
	MPS:PromptProductPurchase(player, id)
end)

Thanks For Your Help Whoever Answers me!

2 comments

0

Im Trying To Make it multiply the users current stats (if he has 20 it should make it 40)

1 answer

✓ Accepted answer

The error that you had was you had Playerid instead of PlayerId. The correct code should be

local MPS = game:GetService("MarketplaceService")


MPS.ProcessReceipt = function(receiptInfo)
    if receiptInfo.ProductId == 985697300 then
        local player = game.Players:GetPlayerByUserId(receiptInfo.PlayerId)
        player.leaderstats.Life.Value = player.leaderstats.Life.Value * 2
        return Enum.ProductPurchaseDecision.PurchaseGranted
    end
end

I tested ingame and it multiplied a value in leaderstats. Let me know any errors!

2 comments

0

Thank You, Your Perfect!

0

ty

This discussion is preserved as it was. New answers, comments, and votes are closed.