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

Why is my script not working?(For ingame products)

Asked by 9 years ago

local DataStoreService=game:GetService("DataStoreService") local PurchaseHistory = DataStoreService:GetDataStore("PurchaseHistory") local MPS=game:getService("MarketplaceService") local GravCoil=game.Lighting:WaitForChild("Gravity Coil")

MPS.ProcessReceipt = function(receiptInfo) print("processing") local playerProductKey = receiptInfo.PlayerId .. ":" .. receiptInfo.PurchaseId if PurchaseHistory:GetAsync(playerProductKey) then return Enum.ProductPurchaseDecision.PurchaseGranted --We already granted it. end -- find the player based on the PlayerId in receiptInfo print("still processing") for i, player in ipairs(game.Players:GetPlayers()) do print(player.Name) if player.userId == receiptInfo.PlayerId then print(player.Name.." bought it") -- check which product was purchased (required, otherwise you'll award the wrong items if you're using more than one developer product) if receiptInfo.ProductId == 21002366 then print("Right id") GravCoil:Clone().Parent = player.Backpack end end end -- record the transaction in a Data Store PurchaseHistory:SetAsync(playerProductKey, true)
-- tell ROBLOX that we have successfully handled the transaction (required) return Enum.ProductPurchaseDecision.PurchaseGranted
end

It used to work, now it doesn't

Answer this question