|
| 10 Jan 2016 01:34 PM |
I am trying to implement developer products into my game with ScreenGUIs, I have the GUI set up and I have tried putting the scripts into StarterPack, StarterGUI, and ReplicatedFirst. Whenever I try to join the game or run test mode in studio ROBLOX freezes and I have to Alt+Tab and close it. Here is the script:
while true do local buyButton = game.StarterGui.ScreenGui.Button3 buyButton.MouseButton1Click:connect(function() local productId = 30218530 game:GetService("MarketplaceService"):PromptProductPurchase(game.Players.LocalPlayer, productId) game.ServerStorage.MoneyStorage.LocalPlayer.Value = game.ServerStorage.MoneyStorage.LocalPlayer.Value + 100000 end) end
I have it in a LocalScript as well.
#code local = OP if OP = noob then print "get out" |
|
|
| Report Abuse |
|
|
|
| 10 Jan 2016 01:35 PM |
U need a wait in your loop.
#Code print("Song Link: http://www.roblox.com/Deorro-vs-Swedish-House-Mafia-Save-The-5-Hours-item?id=340827217") |
|
|
| Report Abuse |
|
|
|
| 10 Jan 2016 01:36 PM |
So would it look like this?
wait(3) while true do local buyButton = game.StarterGui.ScreenGui.Button3 buyButton.MouseButton1Click:connect(function() local productId = 30218530 game:GetService("MarketplaceService"):PromptProductPurchase(game.Players.LocalPlayer, productId) game.ServerStorage.MoneyStorage.LocalPlayer.Value = game.ServerStorage.MoneyStorage.LocalPlayer.Value + 100000 end) end
#code local = OP if OP = noob then print "get out" |
|
|
| Report Abuse |
|
|
|
| 10 Jan 2016 01:38 PM |
Just tried that, it just takes the game an extra 3 seconds to freeze up :/
#code local = OP if OP = noob then print "get out" |
|
|
| Report Abuse |
|
|
|
| 10 Jan 2016 01:38 PM |
while true do wait(3) local buyButton = game.StarterGui.ScreenGui.Button3 buyButton.MouseButton1Click:connect(function() local productId = 30218530 game:GetService("MarketplaceService"):PromptProductPurchase(game.Players.LocalPlayer, productId) game.ServerStorage.MoneyStorage.LocalPlayer.Value = game.ServerStorage.MoneyStorage.LocalPlayer.Value + 100000 end) end
|
|
|
| Report Abuse |
|
|
|
| 10 Jan 2016 01:39 PM |
if u dont want to wait just do
while true do wait() local buyButton = game.StarterGui.ScreenGui.Button3 buyButton.MouseButton1Click:connect(function() local productId = 30218530 game:GetService("MarketplaceService"):PromptProductPurchase(game.Players.LocalPlayer, productId) game.ServerStorage.MoneyStorage.LocalPlayer.Value = game.ServerStorage.MoneyStorage.LocalPlayer.Value + 100000 end) end |
|
|
| Report Abuse |
|
|
|
| 10 Jan 2016 01:40 PM |
The loop is completely unnecessary as well.
local buyButton = game.StarterGui.ScreenGui.Button3 buyButton.MouseButton1Click:connect(function() local productId = 30218530 game:GetService("MarketplaceService"):PromptProductPurchase(game.Players.LocalPlayer, productId) game.ServerStorage.MoneyStorage.LocalPlayer.Value = game.ServerStorage.MoneyStorage.LocalPlayer.Value + 100000 end)
#Code print("Song Link: http://www.roblox.com/Deorro-vs-Swedish-House-Mafia-Save-The-5-Hours-item?id=340827217") |
|
|
| Report Abuse |
|
|
|
| 10 Jan 2016 01:41 PM |
@mine
Thanks, it worked :D
#code local = OP if OP = noob then print "get out" |
|
|
| Report Abuse |
|
|
|
| 10 Jan 2016 01:43 PM |
Heading into the game to test it out.
#code local = OP if OP = noob then print "get out" |
|
|
| Report Abuse |
|
|
|
| 10 Jan 2016 01:45 PM |
Ok, the game loads but when I click the button it does nothing, I also don't see any errors in the developer console. I suspect that the problem is I can't call LocalPlayer inside of ServerStorage. Should I first make a local variable that gets the LocalPlayer's name?
#code local = OP if OP = noob then print "get out" |
|
|
| Report Abuse |
|
|
BanTech
|
  |
| Joined: 31 Dec 2015 |
| Total Posts: 886 |
|
|
| 10 Jan 2016 01:46 PM |
I strongly suggest moving the money increase to this function to prevent someone cancelling the purchase and still receiving the money.
game:GetService("MarketplaceService").ProcessReceipt = function(receiptInfo) if receiptInfo.ProductId == 30218530 then game.ServerStorage.MoneyStorage.LocalPlayer.Value = game.ServerStorage.MoneyStorage.LocalPlayer.Value + 100000 end end |
|
|
| Report Abuse |
|
|
BanTech
|
  |
| Joined: 31 Dec 2015 |
| Total Posts: 886 |
|
|
| 10 Jan 2016 01:47 PM |
Put the script inside the ScreenGui and replace the buyButton line with:
local buyButton = script.Parent:WaitForChild('Button3') |
|
|
| Report Abuse |
|
|
|
| 10 Jan 2016 01:47 PM |
| LocalPlayer = game.Players.LocalPlayer add this |
|
|
| Report Abuse |
|
|
BanTech
|
  |
| Joined: 31 Dec 2015 |
| Total Posts: 886 |
|
|
| 10 Jan 2016 01:50 PM |
and possible change to
game.ServerStorage.MoneyStorage[LocalPlayer.Name].Value |
|
|
| Report Abuse |
|
|
|
| 10 Jan 2016 01:51 PM |
@Ban
Ok, if what Mine said doesn't work I'll try that.
#code local = OP if OP = noob then print "get out" |
|
|
| Report Abuse |
|
|
BanTech
|
  |
| Joined: 31 Dec 2015 |
| Total Posts: 886 |
|
|
| 10 Jan 2016 01:52 PM |
| You need to include my three posts and Mine's latest post for it to work |
|
|
| Report Abuse |
|
|
|
| 10 Jan 2016 01:55 PM |
@Ban
Ok, should I do what mine said or make the LocalPlayer a local variable?
#code local = OP if OP = noob then print "get out" |
|
|
| Report Abuse |
|
|
BanTech
|
  |
| Joined: 31 Dec 2015 |
| Total Posts: 886 |
|
|
| 10 Jan 2016 01:57 PM |
This inside of a LocalScript inside of the ScreenGui:
local marketplace = game:GetService("MarketplaceService") local productId = 30218530 local localPlayer = game.Players.LocalPlayer local buyButton = script.Parent:WaitForChild('Button3')
buyButton.MouseButton1Click:connect(function() marketplace:PromptProductPurchase(localPlayer, productId) end)
marketplace.ProcessReceipt = function(receiptInfo) if receiptInfo.ProductId == 30218530 then game.ServerStorage.MoneyStorage[LocalPlayer.Name].Value = game.ServerStorage.MoneyStorage[LocalPlayer.Name].Value + 100000 end end |
|
|
| Report Abuse |
|
|
|
| 10 Jan 2016 02:00 PM |
@Ban
Thanks, I was having trouble putting all of your suggestions together, I'll try that.
#code local = OP if OP = noob then print "get out" |
|
|
| Report Abuse |
|
|
|
| 10 Jan 2016 02:01 PM |
Also, this isn't supposed to work in studio, is it?
#code local = OP if OP = noob then print "get out" |
|
|
| Report Abuse |
|
|
BanTech
|
  |
| Joined: 31 Dec 2015 |
| Total Posts: 886 |
|
|
| 10 Jan 2016 02:02 PM |
Sorry buddy, one last change (replace last chunk):
marketplace.ProcessReceipt = function(receiptInfo) if receiptInfo.ProductId == 30218530 and receiptInfo.PlayerId == localPlayer.UserId then game.ServerStorage.MoneyStorage[localPlayer.Name].Value = game.ServerStorage.MoneyStorage[localPlayer.Name].Value + 100000 return Enum.ProductPurchaseDecision.PurchaseGranted end end
And yeah this won't work in Studio unless you test it in server mode. |
|
|
| Report Abuse |
|
|
|
| 10 Jan 2016 02:04 PM |
local marketplace = game:GetService("MarketplaceService") local productId = 30218530 local localPlayer = game.Players.LocalPlayer local buyButton = script.Parent:WaitForChild('Button3')
buyButton.MouseButton1Click:connect(function() marketplace:PromptProductPurchase(localPlayer, productId) end)
marketplace.ProcessReceipt = function(receiptInfo) if receiptInfo.ProductId == 30218530 then game.ServerStorage.MoneyStorage[localPlayer.Name].Value = game.ServerStorage.MoneyStorage[localPlayer.Name].Value + 100000 end end
I saved studio and went into the actual game to test it out, it didn't work but I actually see an error this time:
Can only register ProcessReceipt callback on server
(path to script), line 14
#code local = OP if OP = noob then print "get out" |
|
|
| Report Abuse |
|
|
|
| 10 Jan 2016 02:05 PM |
Ok, I just saw your latest post. I'll add that.
#code local = OP if OP = noob then print "get out" |
|
|
| Report Abuse |
|
|
|
| 10 Jan 2016 02:07 PM |
Same error I was getting, can only ProcessReceipt callback on server.
#code local = OP if OP = noob then print "get out" |
|
|
| Report Abuse |
|
|
BanTech
|
  |
| Joined: 31 Dec 2015 |
| Total Posts: 886 |
|
|
| 10 Jan 2016 02:10 PM |
Ah okay, delete the last chunk of it and put a new script into the workspace (regular server script). Insert this:
marketplace = game:GetService("MarketplaceService")
marketplace.ProcessReceipt = function(receiptInfo) local playerName = game.Players:GetPlayerFromUserId(receiptInfo.PlayerId).Name if receiptInfo.ProductId == 30218530 then game.ServerStorage.MoneyStorage[playerName].Value = game.ServerStorage.MoneyStorage[playerName].Value + 100000 end end |
|
|
| Report Abuse |
|
|