Hello! I am Glassphyte, and I seem to be in some trouble and wish for help. I've watched a certain ROBLOX video and what happened in it peaked my interest. I see the user has made a small.. script which allows him to buy a catalog item from his game, by just entering the ID and pressing enter! I attempted to make something like that myself.. but it didn't succeed. I made the screengui somewhat like his, but added a textbox and textbutton. So instead of pressing enter, I press the 'Confirm' button, that's to the side of the textbox. Like I said though, I had no luck.
Can anyone try to help me out with this? Thank you.
Here is the link to his video.
https://www.youtube.com/watch?v=zaB1iEDrWAU
Here is what I've made so far of the script.
01 | -- Script for In-Game Selling |
02 |
03 | local box = script.Parent.Parent:WaitForChild( "TextBox" ) |
04 | local button = script.Parent |
05 |
06 | local ItemID = ( "TextBox" ) |
07 |
08 | script.Parent.ClickDetector.MouseClick:connect( function (player) |
09 | Game:GetService( "MarketplaceService" ):PromptPurchase(player, ItemID) |
10 | end ) |
11 |
12 | -- Made by Glassphyte |
1.If FilteringEnabled is on, do NOT use a script, use a LocalScript.
2.The class "TextButton" does not have a "MouseClick" function, change it to "MouseButton1Click".
3. "local ItemID = ("TextBox")" is not a thing. Instead, use "local ItemID = box.Text"
4.ClickDetectors don't do anything when in a Gui, remove it.
5. Much More.
Here is my answer:
1 | local TextBox = script.Parent.Parent.TextBox --Finds the TextBox |
2 |
3 | local ItemID = TextBox.Text --Gets the string entered. |
4 |
5 | script.Parent.MouseButton 1 Down:Connect( function (Player) --Make sure the script's parent is a TextButton |
6 | Game:GetService( "MarketplaceService" ):PromptPurchase(Player, ItemID) |
7 | end ) |
8 |
9 | -- Totally not made by Glassphyte. It is better. |
01 | local player = game.Players.LocalPlayer |
02 | -- Lowercase 'g'ame |
03 | local MarketplaceService = game:GetService( "MarketplaceService" ) |
04 | local box = script.Parent.Parent:WaitForChild( "TextBox" ) |
05 | local button = script.Parent |
06 |
07 | -- ClickDetectors go in Parts, not GUI's. |
08 | button.MouseButton 1 Down:connect( function () |
09 | -- Match all numbers in your input, else default to 12345 |
10 | local txt = box.Text:match( "%d+" ) or 12345 |
11 | MarketplaceService:PromptPurchase(player, txt) |
12 | end ) |