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

Why is it not giving the player the value?

When a player buys lets say the +50 player points, it does not give them 50 players points only 2...

I hid the numbers, so yeah please tell me what i'm doing wrong!

Is it because i had the extra comma at ["0"]=500,?

local Service = Game:GetService("PointsService")

local Products={
	["0"]=2,
	["0"]=5,
	["0"]=10,
	["0"]=50,
	["0"]=500,
}

local PurchaseHistory = Game:GetService("DataStoreService"):GetDataStore("PurchaseHistory")

Game:GetService("MarketplaceService").ProcessReceipt=function(Receipt)
	local PlayerProductKey = Receipt.PlayerId.."_"..Receipt.PurchaseId
	for _,Player in pairs(Game.Players:GetChildren())do
		if Player.userId==Receipt.PlayerId then
			if PurchaseHistory:GetAsync(PlayerProductKey)then
				return Enum.ProductPurchaseDecision.PurchaseGranted
			end
			for i, v in pairs(Products)do
				if tostring(Receipt.ProductId)==i then
					Service:AwardPoints(Player.userId, v)
					PurchaseHistory:SetAsync(PlayerProductKey, true)
					return Enum.ProductPurchaseDecision.PurchaseGranted
				end
			end
		end
	end
end

1 answer

✓ Accepted answer

The best way to debug is to print data.

Also, isolate part of your code. Get rid of that purchasehistory stuff. Just strictly award points without logging it. I'm not sure what you're doing with that code. It seems to look if the player has purchased points before, if yes, then it doesn't give them any more? No idea.

Now, make your point giving code print the ID of the product you buy, how many points it should award, etc.

Go ingame , press F9 to open a console, and then see what's up.

1 comment

0

How could i remove the purchase history safely?

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