Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

Developer Product error? Speed and Health

Asked by 10 years ago

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

Log in to vote
2
Answered by 10 years ago

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)
0
Do you mind please telling me how you would use it in this case. ConnorVIII 448 — 10y
0
Just edited my anser to include an example. NoahWillCode 370 — 10y
0
Am i able to add more ID's in here? copy and pasting the elseif thing and adding more id's? ConnorVIII 448 — 10y
0
Yep! NoahWillCode 370 — 10y
Ad
Log in to vote
1
Answered by
RAYAN1565 691 Moderation Voter
10 years ago

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.

0
Yes, already done. I need help with the coding ConnorVIII 448 — 10y

Answer this question