Dev Product Not Working

Hi! I made a developer product system and it won’t add the value after being bought. I used it in a different game but it used datastore2, It only works with the 100 coin product. Here is the code:

 local MarketPlaceService = game:GetService("MarketplaceService")
 local DataStoreService = game:GetService("DataStoreService")
 local values = DataStoreService:GetDataStore("values")
 local PrevousPurchases = DataStoreService:GetDataStore("PreviousPurchases")

 local oneHundredCoins = 1131002558
 local oneThousandCoins = 1131002692
 local fiveThousandCoins = 1131002782
 local twentyFiveThousand = 1131002893	
 local fiftyThousandCoins = 1131003070

 local oneHundredThousandCoins = 1131003157
 game.Players.PlayerAdded:Connect(function(player)

MarketPlaceService.ProcessReceipt = function(receipt)

	print("Processing!")

	local value = values:GetAsync(player.UserId.."-values")
	
	local ID = receipt.PlayerId.."-"..receipt.PurchaseId

	local success = nil

	pcall(function()
		success = PrevousPurchases:GetAsync(ID)
		print("Success")
	end)

	if success then
		print("Granted!")
		return Enum.ProductPurchaseDecision.PurchaseGranted
	end

	local player = game.Players:GetPlayerByUserId(receipt.PlayerId)

	if not player then
		print("They Left!")
		-- They left
		return Enum.ProductPurchaseDecision.NotProcessedYet
	else
		local values = DataStoreService:GetDataStore("values")
		print("Got DataStore")
		print(receipt.ProductId)
		if receipt.ProductId == oneHundredCoins then
			print("One Hundred")
			player.leaderstats.Coins.Value = player.leaderstats.Coins.Value + 100
			values:SetAsync(player.UserId.."-values", player.leaderstats.Coins.Value)
			print("Done")
		end

		if receipt.ProductId == oneThousandCoins then
			print("Thousand")
			player.Leaderstats.Coins.Value = player.Leaderstats.Coins.Value + 1000
			values:SetAsync(player.UserId.."-values", player.leaderstats.Coins.Value)
			print("Done")
		end

		if receipt.ProductId == fiveThousandCoins then
			print("Five Thousand")
			player.Leaderstats.Coins.Value = player.Leaderstats.Coins.Value + 5000
			values:SetAsync(player.UserId.."-values", player.leaderstats.Coins.Value)
			print("Done")
		end

		if receipt.ProductId == twentyFiveThousand then
			print("Twenty Five Thousand")
			player.Leaderstats.Coins.Value = player.Leaderstats.Coins.Value + 25000
			values:SetAsync(player.UserId.."-values", player.leaderstats.Coins.Value)
			print("Done")
		end

		if receipt.ProductId == fiftyThousandCoins then
			print("Fifty Thousand")
			player.Leaderstats.Coins.Value = player.Leaderstats.Coins.Value + 50000
			values:SetAsync(player.UserId.."-values", player.leaderstats.Coins.Value)
			print("Done")
		end

		if receipt.ProductId == oneHundredThousandCoins then
			print("One Hundred Thousand")
			player.Leaderstats.Coins.Value = player.Leaderstats.Coins.Value + 100000
			values:SetAsync(player.UserId.."-values", player.leaderstats.Coins.Value)
			print("Done")
			
		end
		pcall(function()
			PrevousPurchases:SetAsynce(ID,true)
		end)
		
		return Enum.ProductPurchaseDecision.PurchaseGranted
	end
end
end)

It prints everything exept for “done” on all but the 100 coin one. There are no errors.

You have typos in your script. You need to have full lowercase “leaderstats” in each update value chunk.

1 Like

Wow I feel stupid. tysm! It works now lol