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

Dev Product not working?

I have these 2 scripts inside a Text Button inside a Surface Gui inside a brick. The Developer Product is to give 20 extra speed intill you die but the gui to buy the Dev Product does not come up.

Script #1: DevProductMain

local developerProduct = 20702452 -- Id of the developer product
local speedInc = 20 --Change this to the amount of Walkspeed you'd like to give.
 
Game:GetService("MarketplaceService").ProcessReceipt = function(receipt)
    if receipt.ProductId == developerProduct then -- the speed dev product
        for i,v in pairs(game.Players:GetPlayers()) do -- loop through the players
            if v.userId == receipt.PlayerId then -- if they're the player that bought it
                if v.Character and v.Character:FindFirstChild("Humanoid") then
                    v.Character.Humanoid.WalkSpeed = v.Character.Humanoid.WalkSpeed + 20 -- add speedinc to their current walkspeed
                end
            end
        end
    end
return Enum.ProductPurchaseDecision.PurchaseGranted
end

and Script #2: MainScript

local marketplaceService = game:GetService("MarketplaceService")
local developerProduct = "http://www.roblox.com/Item-Link-item?id=20702452" -- Item link to the developer product, you must use the WHOLE Link, not just the ID.

local walkspeedButton = script.Parent.BuyWalkspeed
local player = script.Parent.Parent.Parent

function getItemId(developerProduct)
	if tonumber(developerProduct) then
		return tonumber(developerProduct)
	elseif developerProduct:find("id=") then
		a,b = developerProduct:find("id=")
		return tonumber(developerProduct:sub(b+1))
	end
end

devId = getItemId(developerProduct)
function buyDevProduct()
	marketplaceService:PromptProductPurchase(player, devId)
end

walkspeedButton.MouseButton1Down:connect(buyDevProduct)

1 comment

0

To anyone wondering the whole thing is in Workspace

1 answer

This is not even close to right. You need to have one in the players backpack, in a local script. Then the one handling the purchase has to be in the server. The first script is almost right, but leave it in the workspace on it's own. For the second one, it doesn't have to b to fancy, basically, just put this in the players startergui, and it should be fine.

local devID = 20702452 --change this to YOUR DEVELOPER PRODUCT Id.
local buyButton = Workspace.walkspeedbutton.SurfaceGUI.button --change this to the real directory in the workspace
buyButton.MouseButton1Click:connect(function()
	game:GetService("MarketplaceService"):PromptProductPurchase(game.Players.LocalPlayer, devID)
end)

that is what your supposed to do. Where ever you got the these scripts, ithey were really wrong. here is the server script:

local MarketplaceService = Game:GetService("MarketplaceService")
local productId = 20450331 --change this to your dev product id.
-- 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
			if receiptInfo.ProductId == productId then
				local speedInc = 20
					player.Character.Humanoid.WalkSpeed = player.Character.Humanoid.WalkSpeed+speedInc
						end
		end
 
	-- tell ROBLOX that we have successfully handled the transaction
	return Enum.ProductPurchaseDecision.PurchaseGranted		
end

there may be an extra "end" in there, because i took the code out of my place, and edited it for you, so i had to take out the data stores, and the other dev products i had running in here.

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