|
| 05 Jun 2016 06:04 PM |
Hi there, I'm making a tycoon and you know how a tycoon works. :D But I want to make a button in a shop that gives you in-game money from real money. I already have the GUI and the buttons, but not the scripting. It says "100 Dollars - [10R$]", but how do I make it so real money gives the player in-game money? I've searched up on YouTube, but all I've found is how real money gives people in-game clothing. Please help, thanks. ;)
-IllusionYouTube |
|
|
| Report Abuse |
|
|
|
| 05 Jun 2016 06:12 PM |
You'd create a developer product worth 10R$ which can be purchased from the player, and set up code to award $100 in-game whenever it is purchased.
From there, you'd just have to prompt the player to purchase the product when the button is clicked
This should have everything you need: http://wiki.roblox.com/index.php?title=Developer_product
Ignore the parts about saving the purchase with DataStore - in your case it isn't necessary.
Thanks for being polite in your help request, and good luck with your tycoon! |
|
|
| Report Abuse |
|
|
|
| 05 Jun 2016 06:54 PM |
Hello, thanks for all the help. You're awesome! But I don't understand the Wiki page. Do you mind pasting in the coding that I'm supposed to type? I'm really sorry. :( On the Wiki, there are about four scripts and I don't know which one is supposed to go where. It's really vague. So if you don't mind, thanks. Also, is the LocalScript supposed to go under the TextButton?
-IllusionYouTube |
|
|
| Report Abuse |
|
|
|
| 05 Jun 2016 06:59 PM |
I typed:
local productId = 34901403 game.Players.PlayerAdded:connect(function(player) Game:GetService("MarketplaceService"):PromptProductPurchase(player, productId) end)
local MarketplaceService = Game:GetService("MarketplaceService") local buyButton = game.Workspace.BuyButton.SurfaceGui.TextButton local productId = 34901403 buyButton.MouseButton1Click:connect(function() MarketplaceService:PromptProductPurchase(player, productId) end)
local info = game:GetService("MarketplaceService"):GetProductInfo(developerProductId, Enum.InfoType.Product)
--LocalScript in StarterPack -- setup local variables local buyButton = game.Workspace.BuyButton.SurfaceGui.TextButton local productId = 34901403 -- when player clicks on buy brick prompt him/her to buy a product buyButton.MouseButton1Click:connect(function() game:GetService("MarketplaceService"):PromptProductPurchase(game.Players.LocalPlayer, productId) end) --Script in BuyButton part -- setup local variables local MarketplaceService = Game:GetService("MarketplaceService") local ds = game:GetService("DataStoreService"):GetDataStore("PurchaseHistory") local productId = 34901403 -- define function that will be called when purchase finished MarketplaceService.ProcessReceipt = function(receiptInfo) -- find the player based on the PlayerId in receiptInfo for i, player in ipairs(game.Players:GetChildren()) do if player.userId == receiptInfo.PlayerId then -- check which product was purchased if receiptInfo.ProductId == productId then -- handle purchase player.leaderstats.Money.Value = player.leaderstats.Money.Value + 5 end end end -- record the transaction in a Data Store local playerProductKey = "player_" .. receiptInfo.PlayerId .. "_purchase_" .. receiptInfo.ProductId ds:IncrementAsync(playerProductKey, 1) -- tell ROBLOX that we have successfully handled the transaction return Enum.ProductPurchaseDecision.PurchaseGranted end |
|
|
| Report Abuse |
|
|
eRanged
|
  |
| Joined: 15 Jun 2013 |
| Total Posts: 9746 |
|
|
| 05 Jun 2016 07:48 PM |
--Client
local player = game.Players.LocalPlayer local MarketService = game:GetService("MarketplaceService") local MoneyButton = "INSERT LOCATION TO MONEYBUTTON" local ProductID = 0 --Change to ProductID
MoneyButton.MouseButton1Click:connect(function() MarketService:PromptProductPurchase(player, ProductID) end)
--Server local MarketService = game:GetService("MarketplaceService") local ProductID = 0 --Change to ProductID
MarketService.PromptProductPurchaseFinished:connect(function(userID, productID, isPurchased) local player = game.Players:GetPlayerByUserId(userID) if isPurchased == true then --If he bought product if productID == ProductID then --If he bought specific Product print(player.Name .. ' has bought Product: ' .. productID) end end end)
|
|
|
| Report Abuse |
|
|
|
| 05 Jun 2016 09:49 PM |
| Hi, um... What do you mean by ""INSERT LOCATION TO MONEYBUTTON""? Do you mean the LocalScript's parent? |
|
|
| Report Abuse |
|
|
eRanged
|
  |
| Joined: 15 Jun 2013 |
| Total Posts: 9746 |
|
|
| 06 Jun 2016 07:23 AM |
| I mean the button you are clicking |
|
|
| Report Abuse |
|
|