Need help for a dev product cash booster script

so i got this script in serverscriptservice

local DataStoreService = game:GetService("DataStoreService")
local LeaderstatDataStore = DataStoreService:GetDataStore("LeaderstatDataStore")
local DeveloperProductID = script.id.Value
game.Players.PlayerAdded:Connect(function(player)
	local Leaderstat = player.leaderstats.Cash
	local LeaderstatKey = player.UserId .. "Cash"

	local success, savedValue = pcall(function()
		return LeaderstatDataStore:GetAsync(LeaderstatKey)
	end)
	if success and savedValue then
		Leaderstat.Value = savedValue
	end
	local PurchasedFlagKey = player.UserId .. "_Purchased"
	local purchasedSuccess, purchasedValue = pcall(function()
		return LeaderstatDataStore:GetAsync(PurchasedFlagKey)
	end)
	if not purchasedSuccess or purchasedValue == nil then
		purchasedValue = false
	end
	if not purchasedValue then
		game:GetService("MarketplaceService").ProcessReceipt = function(receiptInfo)
			if receiptInfo.PlayerId == player.UserId and receiptInfo.ProductId == DeveloperProductID then
				Leaderstat.Value = Leaderstat.Value + script.Cash.Value
				local purchaseSuccess, purchaseError = pcall(function()
					LeaderstatDataStore:SetAsync(PurchasedFlagKey, true)
				end)
				if not purchaseSuccess then
					warn("Failed to save purchase data:", purchaseError)
				end
				local saveSuccess, saveError = pcall(function()
					LeaderstatDataStore:SetAsync(LeaderstatKey, Leaderstat.Value)
				end)
				if not saveSuccess then
					warn("Failed to save Cash data:", saveError)
				end
			end
			return Enum.ProductPurchaseDecision.PurchaseGranted
		end
	end
end)

image

heres the GUI script:

local button = script.Parent
local player = game.Players.LocalPlayer
local gamePassId = script.Parent.GamepassId

button.MouseButton1Click:connect(function()
	if player then
		game:GetService("MarketplaceService"):PromptProductPurchase(player, gamePassId.Value)
	end
end)

and the gui prompt works fine but the server script doesnt give cash once bought the dev product + it gives no error at all

2 Likes

Studio ProcessReceipt question - #2 by Lava_shield check out this post and see if it solves your problem

i tried disabling every other script with the thing but it still doesnt work

Yeah it wont work if you are using more than one dev product because of the way the callback works

ok so it works but only if i disable a donation board script which idk how to put together with this cash one (nvm i fixed)

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.