So I’ve been trying to make this thing work for ages know and I thought what better way then to see if you guys can help me
- ServerScriptService Script
- The Ui/Button
My API services are on same as third party sales
So I’ve been trying to make this thing work for ages know and I thought what better way then to see if you guys can help me
My API services are on same as third party sales
Copy and paste them here, thanks.
Ui Button Code:
local MPS = game:GetService(“MarketplaceService”)
local id = 1214262048
local plr = game.Players.LocalPlayer
script.Parent.MouseButton1Click:Connect(function()
MPS:PromptProductPurchase(plr,id)
end)
ServiceScriptService Code:
local mps = game.GetService(“MarketplaceService”)
mps.ProcessReceipt = function(receiptInfo)
if receiptInfo.ProductId == 1214262048 then
local plr = game.Players:GetPlayerByUserId(receiptInfo.PlayerId)
plr.leaderstats.Cash.Value = plr.leaderstats.Cash.Value + 500
return Enum.ProductPurchaseDecision.PurchaseGranted
end
if receiptInfo.ProductId == 121426048 then
local plr = game.Players:GetPlayerByUserId(receiptInfo.PlayerId)
plr.leaderstats.Cash.Value = plr.leaderstats.Cash.Value + 1000
return Enum.ProductPurchaseDecision.PurchaseGranted
end
end
local MPS = game:GetService("MarketplaceService")
local productId = 1214262048
local plr = game.Players.LocalPlayer
local button = script.Parent
button.MouseButton1Click:Connect(function()
MPS:PromptProductPurchase(plr, productId)
end)
local MPS = game:GetService("MarketplaceService")
local Plrs = game:GetService("Players")
local function processReceipt(receiptInfo)
if receiptInfo.ProductId == 1214262048 then
local plr = Plrs:GetPlayerByUserId(receiptInfo.PlayerId)
local cash = plr:WaitForChild("leaderstats"):WaitForChild("Cash")
if plr and cash then
cash.Value += 500
return Enum.ProductPurchaseDecision.PurchaseGranted
else
return Enum.ProductPurchaseDecision.NotProcessedYet
end
end
if receiptInfo.ProductId == 121426048 then
local plr = Plrs:GetPlayerByUserId(receiptInfo.PlayerId)
local cash = plr:WaitForChild("leaderstats"):WaitForChild("Cash")
if plr and cash then
cash.Value += 1000
return Enum.ProductPurchaseDecision.PurchaseGranted
else
return Enum.ProductPurchaseDecision.NotProcessedYet
end
end
end
MPS.ProcessReceipt = processReceipt
are they both for local scripts because if so it didn’t work even in the real game
Of course not, the top one is a local script which goes inside the button being pressed.
The second one is a server script which goes inside the ServerScriptService folder.
The problem is you arent checking if the players user id in the ServerScript is equal to the one in the LocalScript.
Nah, I think he was just using the wrong script types/wrong locations etc.
WRONG TOPIC LOL! I am so sorry, I had to read the topic over before I realized I was doing a totally different comment. I have had around 2 different gamepass/dev product topics I commented on today.
There is no Instance.new() call, I think you’re responding to the wrong thread.
But yes, you should always check if the player’s UserId is equal to the one purchasing it.
That’s not necessary, the local script (which manages the Gui) is just for prompting the purchase, receipt handling is performed solely on the server.
https://developer.roblox.com/en-us/api-reference/callback/MarketplaceService/ProcessReceipt
Here you go.
Actually, I just re-read the script, and I was wrong. The player variable was getting the player’s UserId from the receiptInfo. Nevermind!
it didnt work when i replace it
You made a spelling mistake. Replace the ServerScript line 1 with:
local mps = game:GetService("MarketplaceService")
who are you talking to me or Forummer?
This text will be blurredYou!
Thank you it works know! lol all because of a typo