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

hi need help with developer products?

ive been at this for almost 2 days somehow lol..

everytime i click the gui button doesnt do anything

and every kit i used when i test it it doesnt give me the item or stats i want it to give so i ended up trying to do it my self i even tried zed's kit and cant even give my character more maxhealth or walkspeed with that

anyway heres the code for the button also was following the directions from the wiki tutorial..

--Script in BuyButton part
-- setup local variables
local MarketplaceService = Game:GetService("MarketplaceService")
local ds = game:GetService("DataStoreService"):GetDataStore("PurchaseHistory")
local productId = 122666336

-- 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
				game.ServerStorage.Minigun:Clone().Parent=player.Backpack
			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


and heres the script from in the starter pack

local mGunButton = game.StarterGui.ShopGui.Buttons.minigun
local speedButton = game.StarterGui.ShopGui.Buttons.speed
local maxHealthButton = game.StarterGui.ShopGui.Buttons.maxhealth
local mGunId = 122666336
local speedId= 122666411
local maxHealthId= 122666717
 
-- when player clicks on buy brick prompt him/her to buy a product
mGunButton.MouseButton1Click:connect(function()
	game:GetService("MarketplaceService"):PromptProductPurchase(game.Players.LocalPlayer, mGunId)
end)

speedButton.MouseButton1Click:connect(function()
	game:GetService("MarketplaceService"):PromptProductPurchase(game.Players.LocalPlayer, speedId)
end)
 
maxHealthButton.MouseButton1Click:connect(function()
	game:GetService("MarketplaceService"):PromptProductPurchase(game.Players.LocalPlayer, maxHealthId)
end)
 

please help

1 answer

✓ Accepted answer
local mGunButton = game.StarterGui.ShopGui.Buttons.minigun
local speedButton = game.StarterGui.ShopGui.Buttons.speed
local maxHealthButton = game.StarterGui.ShopGui.Buttons.maxhealth

These three lines are why it doesn't work. They reference StarterGui, and not the PlayerGui. Hopefully, this is a local script. If it is, you'll add local player = game.Players.LocalPlayer at the top and change each game.StarterGui to player.PlayerGui. If it is for some reason a server script, just do the same steps, but instead putting local player = script.Parent.Parent.

Hope this helped!

Thanks,

Explosion

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