Can we create and delete developer products from scripts? - Custom Amount Donation Board

Hello there,
I had this idea of making a custom amount donation board where the player enters their donation amount and they get a prompt for buying a developer product of that amount. The only way to achieve this seems to be by creating developer products from scripts and deleting them after purchase or cancellation.

I made this topic because I wasn’t able to find anything on the wiki.

1 Like

You can make api calls with some proxy to make the product, then delete it, it will have to be a session on the server as remotes are too risky

2 Likes

I’m assuming that that’s the only way to make a custom amount donation board or something.

1 Like

That would be correct. You can’t make any calls to do this from in Roblox itself with a script.

1 Like

There should’ve been a feature which would help developers in making a custom amount thingy.

If you want to create “custom amounts” then just create 1, 5, 10, 50, 100, etc. gamepasses and repeatedly prompt the player to buy the asset. Their total will be equal to the amount they wanted to spend on donating.

While I agree with that. They’re typically used for things such as currency purchases, or getting to continue a game from where you just failed.

The intent wasn’t to be for donations at first, but that’s one of the major uses people have found for them. The way most people do it is just by having increments, 5, 10, 50, 100, 500, 1000.

I want the player to have freedom and allow him to donate whatever amount he wants to donate.
It’s for everything not just donations.

I think this is called “change making”.

Here is some example code I just wrote.

local Prices = {
    100,
    50,
    10,
    5,
    1
}

--// Make sure table is sorted highest to lowest
table.sort(Prices, function(A, B)
    return A > B
end)

local InputDonation = 123
local Change = {}

for Name, Value in pairs(Prices) do
    local Copies = math.floor(InputDonation / Value)
    local Remainder = InputDonation % Value

    Change[Name] = Copies

    if (Remainder == 0) then
        break
    end

    InputDonation = Remainder
end

for i, v in pairs(Change) do
    local Price = Prices[i]

    print(Price, v) --// you would prompt price "Price" to the player "v" times
end

And the example output would be:

100	1
50	0
10	2
5	0
1	3

And this makes sense because, one 100 + two 10 + three 1 = 100 + 10 + 10 + 1 + 1 + 1 = 123

2 Likes

This is a good way but will also frustrate the player by having to buy multiple products for the amount he wants to donate.

This is the easiest way to do what you’re trying to accomplish.

Unless you have a deep understanding of Roblox, can grab your token, add the product on the web, grab the id, prompt it to them, then remove it.

It should not take more than 3 or 4 products for any reasonable donation depending on your coin values? And if they truly care about donating they are not going to get annoyed over a few prompts. (And even if they are, the highest value prompts must be bought first, so you will get the majority of the donation’s original intent value)

Creating 100000 donation assets just does not seem like a good idea to me :

1 Like

Hm, if Roblox has a value in player’s data which determines the cost of what the user will buy next in robux, it might just be very simple. No developer products needed. We could just change that value whenever user clicks on buying things. It won’t mess if they cancel.

I’m not sure I fully understand what you’re trying to say here.

But also, what is the use case for this which allows the user to donate an amount they want?

If they’re already going to donate, they aren’t going to do some random amount like 4769R$, they’re going to do something easy like, 10, 50, 100, etc

Resource if interested

1 Like

it is already simple enough the player in the example I provided. ALL they do is click their mouse until prompts stop coming up.

1 Like

Just tried the demo place, and it’s still trying to load it, so I don’t think that it’s actually still up and running for their demo place, which could mean that either their security token is outdated, or it’s broken.

It probably still works, just the token needs to be refreshed, as only a month ago the original poster said that it was working

Well, for example, User A has a value in him. He enters amount 4769R$ and presses proceed. Then we change value in player by game.Players.LocalPlayer.Value =4769 (suppose) , it triggers purchase prompt for the same amount which is in his value. Now, this happens whenever he clicks for purchasing something. New amount is set and the user buys for that amount and if the purchase is successful, he gets the thing.

Just tried it and it does work, maybe I’ll use it.