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

Developer products; output error "Studio API access is not enabled"?

Does that mean that my game must have save features in order to use developer products?

My script is located inside of a StartMenu Gui, and localscript.

Player = game.Players.LocalPlayer
Menu = script.Parent
Play = Menu.Play
Pack1 = Menu.Pack1
Pack2 = Menu.Pack2

function PlayGame()
	Menu:remove()
end
Play.MouseButton1Down:connect(PlayGame)

function Buy1()
	--LocalScript in StarterPack
-- setup local variables
local buyButton = Pack1
local productId = 20518668
 
-- when player clicks on buy brick prompt him/her to buy a product
buyButton.MouseButton1Click:connect(function()
	game:GetService("MarketplaceService"):PromptProductPurchase(game.Players.LocalPlayer, productId)
end)
 
 
 
 
--Script in BuyButton part
-- setup local variables
local MarketplaceService = Game:GetService("MarketplaceService")
local ds = game:GetService("DataStoreService"):GetDataStore("PurchaseHistory")
local productId = 32819339
 
-- define function that will be called when purchase finished
MarketplaceService.ProcessReceipt = function(receiptInfo) 
 
	-- find the player based on the PlayerId in receiptInfo
	for i, player in ipairs(game.Players:GetChildren()) do
		if player.userId == receiptInfo.PlayerId then
 
 
			-- check which product was purchased
			if receiptInfo.ProductId == productId then
 
				-- handle purchase
				player.leaderstats.Money.Value = player.leaderstats.Cash.Value + 1000000
			end
		end
	end	
 
	-- record the transaction in a Data Store
	local playerProductKey = "player_" .. receiptInfo.PlayerId .. "_purchase_" .. receiptInfo.ProductId
	ds:IncrementAsync(playerProductKey, 1)	
 
	-- tell ROBLOX that we have successfully handled the transaction
	return Enum.ProductPurchaseDecision.PurchaseGranted		
end
end
Pack1.MouseButton1Down:connect(Buy1)

1 comment

1

Game page -> ... -> Configure this Game -> Enable Studio Access to API Services

1 answer

✓ Accepted answer

The answer isn't in studio, confusing eh? First go to the Develop page. Then click on the game, not place, but game. Then go to Basic Settings>Enable Studio Access to API Services, then click it on.

Example Image, click here.

4 comments

0

Will this enable people to copy my place though?

0

No, that's only if you un-copylock the place, which you're not doing.

0

^

0

Awesome. Thanks a bunch guys!

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