In my game the things you can buy are abilities which are activated by pressing the "E" Key. So the abilities are scripts. Is there a way of saving these scripts (Specifically), when a player has gotten them? Maybe changing around this script that saves in game purchases. Such as Developer products.

local MarketplaceService = Game:GetService("MarketplaceService")
local developerProductAmount = 10
 
MarketplaceService.ProcessReceipt = function(receiptInfo)
	-- create variable for player data
	local playerData = PlayerDataStore:GetSaveDataById(receiptInfo.PlayerId)
	-- create update function for purchase history and ingame money for player data
	playerData:Update({'Purchases', 'InGameMoney'}, function(oldPurchases, oldMoney)
		-- create purchases table if it does not exist yet
		if not oldPurchases then oldPurchases = {} end
		-- check if this transaction has already been processed via purchaseId
		if not oldPurchases[receiptInfo.PurchaseId] then
			-- this transaction hasn't been processed	
			-- if player did not have money before start money at 0
			if not oldMoney then oldMoney = 0 end
			-- give player in-game money
			oldMoney = oldMoney + developerProductAmount
			-- flag purchase as handled
			oldPurchases[receiptInfo.PurchaseId] = true
		end
		return oldPurchases, oldMoney
	end)
	return Enum.ProductPurchaseDecision.PurchaseGranted
end

3 comments

0

Saving the script/abilities name to their abilities data store is a simple idea.

0

Im just not very familier with this script specificly (Data Stores) Bascily one of the only few scripts I havent familerized myself with yet.

0

Is there a specific place you would reccomend to learn about this specificly? And please not roblox wiki I have already checked that out.