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

Value doesn't change after buying Developer Product?

This is my button script:

local player = game.Players.LocalPlayer
local Market = game:GetService("MarketplaceService")
id = 984081930

script.Parent.MouseButton1Click:Connect(function()
	Market:PromptProductPurchase(player,id)
end)

This is my serverscript:

local Market = game:GetService("MarketplaceService")

Market.ProcessReceipt = function(receiptInfo)
	if receiptInfo.ProductId == "984081930" then
		game.Workspace.InvincibilityActivated.Value = false
		print("Activated!")
		wait(30)
		game.Workspace.InvincibilityActivated.Value = true
		print("Expired")
		return Enum.ProductPurchaseDecision.PurchaseGranted
	end
end

It doesn't seem to change the Value.

1 answer

✓ Accepted answer

I guess heres a fixed serverscript?

local MarketplaceService = Game:GetService("MarketplaceService")

local P1 = 984081930

MarketplaceService.ProcessReceipt = function(receiptInfo)
	local Player = Game.Players:GetChildren()
	for i = 1, #Player do
		if Player[i].userId == receiptInfo.PlayerId then
			prodId = tonumber(receiptInfo.ProductId)
			if prodId == P1 then
				game.Workspace.InvincibilityActivated.Value = false
       				print("Activated!")
        			wait(30)
      				game.Workspace.InvincibilityActivated.Value = true
        			print("Expired")
			else
				--Error
			end
		end
	end

	return Enum.ProductPurchaseDecision.PurchaseGranted
end

2 comments

0

Could you give me an explanation?

0

Not very good at that.

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