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

Why is this Developer product script not working?

Asked by
DanzLua 2879 Moderation Voter Community Moderator
9 years ago
--[[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

Log in to vote
1
Answered by
Merely 2122 Moderation Voter Community Moderator
9 years ago

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.

Ad

Answer this question