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

Why is this Developer product script not working?

--[[This script goes inside of a TextBox which should be inside of a ScreenGui]]
productId = 21073044 -- Replace 123123123 with the id of your developer product.

local MarketplaceService = Game:GetService("MarketplaceService")
function UsernameFromID(ID)
	if type(ID) ~= "number" then
	return
	end
	local sets = game:service("InsertService"):GetUserSets(ID)
	for k, v in next, sets do
		if v.Name == "My Models" then
			return v.CreatorName
		end
	end
end

MarketplaceService.ProcessReceipt = function(receiptInfo)
	giveRewards(UsernameFromID(receiptInfo.PlayerId))
	UsernameFromID.Character.Humanoid.Health = 0
end
script.Parent.MouseButton1Down:connect(function()
	Game:GetService("MarketplaceService"):PromptProductPurchase(script.Parent.Parent.Parent.Parent, productId)
end)

;)

1 answer

✓ Accepted answer

This definitely will throw an error in online mode. Press F9 while playing a game to open up the Developer Console. You'll be able to see the line number that the error is being thrown on.

I see a few problems:

  1. giveRewards function is not defined
  2. UsernameFromID returns a string, so you can't get the Character directly from the string like you did on line 19.

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