✓ Accepted answer
Remember, get all players with :GetPlayers() no with :GetChildren(), if :GetChildren() you can catch another instance that is not a player!
For first, you need to return Enum.ProductPurchaseDecision.PurchaseGranted on purchase ends!
If not finished purchase you need to use return Enum.ProductPurchaseDecision.NotProcessedYet
You can simple get player with game.Players:GetPlayerByUserId
Wiki page: Purchase in game/Dev products - GetPlayerByUserId
And use can use game:GetService("MarketplaceService") is better than game.MarketplaceService
Here is a example:
game:GetService("MarketPlaceService").ProcessReceipt = function(receiptinfo)
local player = game:GetService("Players"):GetPlayerByUserId(receiptinfo.PlayerId)
if player then
print("Player in game!")
return Enum.ProductPurchaseDecision.PurchaseGranted
else
print("Player leaved or not found!")
return Enum.ProductPurchaseDecision.NotProcessedYet
end
end
Here is your script fixed:
local market = game:GetService("MarketplaceService")
local id = 426035268
function purchasedskiplv(plr)
if plr:FindFirstChild("Stats") then
if plr["Stats"]:FindFirstChild("LV") then
plr.Stats.LV.Value = plr.Stats.LV.Value + 1
end
end
end
market.ProcessReceipt = function(receiptinfo)
local player = game:GetService("Players"):GetPlayerByUserId(receiptinfo.PlayerId)
if player and receiptinfo.ProductId == id then
purchasedskiplv(player)
return Enum.ProductPurchaseDecision.PurchaseGranted
else
print("Can not get player!")
return Enum.ProductPurchaseDecision.NotProcessedYet
end
end
Hope it helped :)
1 comment
Nice, juicy answer ;3