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

Developer Product error? Speed and Health

I made 2 scripts. They are for developer products, yet they dont give the player the speed or health when the Product is purchased. So the script must be wrong somewhere. Both scripts are in Workspace.

Game:GetService("MarketplaceService").ProcessReceipt = function(receipt)
if receipt.ProductId == 0000000 then
for i,v in pairs(game.Players:GetPlayers()) do
if v.userId == receipt.PlayerId then
v.Character.Humanoid.MaxHealth = v.Character.Humanoid.MaxHealth + 100
wait(0.1)
v.Character.Humanoid.Health = v.Character.Humanoid.MaxHealth
end
end
end
end

Script 2

Game:GetService("MarketplaceService").ProcessReceipt = function(receipt)
if receipt.ProductId == 0000000 then
for i,v in pairs(game.Players:GetPlayers()) do
if v.userId == receipt.PlayerId then
v.Character.Humanoid.WalkSpeed= v.Character.Humanoid.WalkSpeed + 5
end
end
end
end

2 answers

✓ Accepted answer

Stop using ProcessReceipt. ProcessReceipt is wildly misunderstood because of one bad Wiki article. Instead, just use the MarketplaceService.PromptProductPurchaseFinished event. Here's an example:

local speedUpgradeId = 1
local healthUpgradeId = 2
--Change the above two values to the appropriate product IDs.

local mpService = game:GetService("MarketplaceService")
 
mpService .PromptProductPurchaseFinished:connect(function(plr, assetId, isPurchased)
	if isPurchased and plr.Character then
		if assetId == speedUpgradeId then
			plr.Character.Humanoid.Walkspeed = plr.Character.Humanoid.Walkspeed + 1
		elseif assetId == healthUpgradeId then
			plr.Character.Humanoid.MaxHealth = plr.Character.Humanoid.MaxHealth + 10
		end
	end
end)

4 comments

0

Do you mind please telling me how you would use it in this case.

0

Just edited my anser to include an example.

0

Am i able to add more ID's in here? copy and pasting the elseif thing and adding more id's?

0

Yep!

Are you replacing the "0000000" with the ID of the product being bought?

if receipt.ProductId == 0000000 then --replace the 0's with the product ID being bought

If not then do so.

Find the ID of the product from the link, for example, let's say this gamepass is the product for VIP in my game:

http://www.roblox.com/5000-Materials-Bonus-item?id=173598478

I would the take the numbers after "http://www.roblox.com/5000-Materials-Bonus-item?id=" which is 173598478 and replace the 0's with those numbers.

1 comment

0

Yes, already done. I need help with the coding

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