Hey there!
Would anyone be able to help me with this script? I would really appreciate it.
Right, so this script (when purchased a dev product) won't work. I don't know is it the button script, or the script that has the MarketplaceService.ProcessReceipt in it.
Whenever I buy the first product it works and gives me, though when I buy the second, it doesn't work. Just doesn't give me no value.
Also the button script is located in a gui. Then, a frame with all the buttons in it. Just some extra information!
Would anyone know what the problem is?
Is it the button script or the main script?
I'd really love some help and thank you so much for reading. It means a lot and I really appreciate that you even clicked on this to help me. All that just means so much to me. :)
Button script:
for i,v in pairs(script.Parent.Buttons:GetChildren()) do
if v:isA("TextButton") then
v.MouseButton1Click:connect(function()
pcall(function()
if v:FindFirstChild("Pass") then
for i,v in pairs(script.Parent.Buttons:GetChildren()) do
if v:isA("TextButton") then
v.MouseButton1Click:connect(function()
pcall(function()
if v:FindFirstChild("Pass") then game.MarketplaceService:PromptPurchase(game.Players.LocalPlayer,tonumber(v.Name)) else game.MarketplaceService:PromptProductPurchase(game.Players.LocalPlayer,tonumber(v.Name))
end
end)
end)
end
end
Main 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 == 1135297211 then
local stats= game.ServerStorage.PlrFolder
local pf= stats:FindFirstChild(player.Name)
stats:FindFirstChild(player.Name)
local strength = pf.Strength
if strength then
pf.Strength.Value = pf.Strength.Value + 5
elseif
productId ==1135297212 then
local stats= game.ServerStorage.PlrFolder
local pf= stats:FindFirstChild(player.Name)
stats:FindFirstChild(player.Name)
local strength = pf.Strength
if strength then
pf.Strength.Value = pf.Strength.Value + 20
end
end
return Enum.ProductPurchaseDecision.PurchaseGranted
end

6 comments
How do I do that?
in your case you would click Ctrl + A to select whole code and then Alt + Shift + F to format the document (Or button on top of studio called format document)
Thanks, but my script still doesn't work.
Then you probably did something wrong.
But I get no such error in the console. So what would I do wrong?
Again, you've stuck an if statement below a different if statement that can never happen. You need to fix the indention and your end placements.