How do I make a script that lets you type in an ID from the catelog and lets you purchase it but gives you a percentage of your purchase back aswell as giving me robux?
I need help!
I don’t think Roblox implement the feature where you buy something, you get some robux back.
You can use PromptPurchase to allow users to buy items from the website as long as you have third-party sales enabled.
However, everything else you mentioned is currently impossible sadly.
Wait actually I think it got patched! Never mind.
Thanks!
How do I add it to a gui so that when you type an item id in the box and press (buy) it brings the purchase prompt for that specific item?
This is a pretty basic script. Let me give me a step by step guide.
First we want to want to get the marketplace service as a variable using this;
local marketplaceservice = game:GetService("MarketplaceService")
We then use this command that detects if the GUI has been clicked, (it must be a Text Button or Image Button)
Note that all this code must be in a local script and the textbutton / image button must be the parent of the script
local marketplaceservice = game:GetService("MarketplaceService")
script.Parent.MouseButton1Click:Connect(function()
end)
Then what we want to do is make the prompt. This is also pretty simple, it used the function :PromptPurchase()
If you are using Developer Products, you must use :PromptProductPurchase()
local marketplaceservice = game:GetService("MarketplaceService")
script.Parent.MouseButton1Click:Connect(function()
marketplaceservice:PromptPurchase(game.Players.LocalPlayer, 6280405130) -- Change this ID to your item's ID
end)
Here is an example of how it works.
See more at MarketplaceService:PromptPurchase
Thanks so much!
I have a few questions.
- I want to make a box which a player pastes the ID of any item that is purchasable on the catelog and when they click the button it pops up the purchase prompt of that particular item. How do you do that?
Because its not my item ID it is an id a player types into the box which they buy
you put a text box then you make you will have to paste text in it, I recommend learning about text boxs, you can probably make the text box into the screengui and define it as script.Parent.Textbox and instead of the ID you put script.Parent.Textbox.Text
You can index your textbox and get the text of it (Textbox.Text
) assuming its a localscript
I said the same thing, but your phrasing is better.
Sure thing! Let me explain,
Basically you will need to use a textbox for inserting custom text for players.
Then you will need to add some sort of button that submits the ID.
For this example I will use my previously written script.
local marketplaceservice = game:GetService("MarketplaceService")
script.Parent.MouseButton1Click:Connect(function()
marketplaceservice:PromptPurchase(game.Players.LocalPlayer, 6280405130) -- Change this ID to your item's ID
end)
Basically in order to make this work we will need to change a few things.
For this script, please make sure the text button’s parent is the textbox and this script’s parent is the text button.
We will first detect what the player has put in the box
script.Parent.MouseButton1Click:Connect(function()
local input = script.Parent.Parent.Text
end)
Now we use what we did before but change one thing
local marketplaceservice = game:GetService("MarketplaceService")
script.Parent.MouseButton1Click:Connect(function()
local input = script.Parent.Parent.Text
marketplaceservice:PromptPurchase(game.Players.LocalPlayer, input) -- Change the numbers to "input"
end)
Above is the full script. It should be in this order.
Here is an example of how it works
Note that in order to allow everything on the catalog to work, you must go to Game Setting > Security > and enable Third Party Sales
you can also define it directly without the “input” variable. It’s probably better putting the variable but just “in case” you can remove it if you want.
I know, just thought it would be easier to know what does what so he can learn.
You want to make a local script which handles the Textbox and UI elements
Then once the player enters the ID, make sure that the text they are entering is an actual number. Like so:
local number = tonumber(textbox.Text)
if number then
MarketplaceService:PromptPurchase(player,number)
end
Pretty smart idea, I like it. 10/10
We already told him what to do, if you didn’t read the comments, NotDerpyDemon already explained the whole thing. And also why cant i stop saying his name?
I did, but the script they provided isn’t necessarily the best it can be, so I added on by using tonumber()
You also didn’t add the events, if you only specified to write the snippet in the event you could’ve said that.