|
| 29 Apr 2016 06:23 AM |
local Player = game.Players.LocalPlayer local ID = 33929599
function onClick() game:GetService("MarketplaceService"):PromptProductPurchase(Player,ID) end
script.Parent.MouseButton1Click:connect(onClick)
|
|
|
| Report Abuse |
|
|
WoolHat
|
  |
| Joined: 19 May 2013 |
| Total Posts: 1873 |
|
|
| 29 Apr 2016 06:39 AM |
| Pretty sure purchase promos must be handled by a server script |
|
|
| Report Abuse |
|
|
Salinas23
|
  |
| Joined: 28 Dec 2008 |
| Total Posts: 37141 |
|
|
| 29 Apr 2016 07:19 AM |
| yup needs to be a server script |
|
|
| Report Abuse |
|
|
|
| 29 Apr 2016 08:14 AM |
| Are you all sure, because I'm pretty sure I managed to make a prompt purchase from local player. How strange... |
|
|
| Report Abuse |
|
|
Salinas23
|
  |
| Joined: 28 Dec 2008 |
| Total Posts: 37141 |
|
|
| 29 Apr 2016 08:26 AM |
nope you didnt
needs to be server script |
|
|
| Report Abuse |
|
|
|
| 29 Apr 2016 08:35 AM |
| Ah, never mind, my game did PromptPurchase, not PromptProductPurchase. |
|
|
| Report Abuse |
|
|
|
| 29 Apr 2016 09:25 AM |
KeiRo, are you saying I should do:
local Player = game.Players.LocalPlayer local ID = 33929599
function onClick() game:GetService("MarketplaceService"):PromptPurchase(Player,ID) end
script.Parent.MouseButton1Click:connect(onClick) |
|
|
| Report Abuse |
|
|
|
| 29 Apr 2016 09:25 AM |
| How would I write this in server code, I am trying to make it so when they click a button on a gui, it prompts them to buy a gamepass. |
|
|
| Report Abuse |
|
|
|
| 29 Apr 2016 11:06 AM |
well the server code is pretty easy just edit
script.Parent.MouseButton1Click:connect(onClick)
and remove the script.Parent and find where the gui is located or u can use remoteevents
|
|
|
| Report Abuse |
|
|
|
| 29 Apr 2016 11:08 AM |
| You would also need to make sure it only prompts the player who clicked the button and not the whole server. |
|
|
| Report Abuse |
|
|
|
| 29 Apr 2016 02:14 PM |
| How would I make it only prompt the person who clicked it? |
|
|
| Report Abuse |
|
|
|
| 29 Apr 2016 02:28 PM |
it needs to be a localscripts..promptpurchase for gamepasses, promptproductpurchase for dev products
|
|
|
| Report Abuse |
|
|
|
| 29 Apr 2016 04:03 PM |
right now i have a local script in the workspace with this and it still won't work.
local Player = game.Players.LocalPlayer local ID = 33929599
function onClick() game:GetService("MarketplaceService"):PromptProductPurchase(Player,ID) end
game.StarterGui.Tips.ImageButton.MouseButton1Click:connect(onClick) |
|
|
| Report Abuse |
|
|
WoolHat
|
  |
| Joined: 19 May 2013 |
| Total Posts: 1873 |
|
|
| 29 Apr 2016 04:09 PM |
| Detect the click via local script, then fire a remotefunction to a server script to prompt the transaction. |
|
|
| Report Abuse |
|
|
|
| 29 Apr 2016 04:15 PM |
| and how exactly would I do that? I'm not familiar with remote functions. |
|
|
| Report Abuse |
|
|
|
| 29 Apr 2016 04:23 PM |
ok so i have this and it still won't work: IN LOCAL SCRIPT IN IMAGE BUTTON: function onClick() game.Workspace.Purchase:FireServer() end
script.Parent.MouseButton1Click:connect(onClick)
IN SCRIPT IN WORKSPACE: local ID = 33929599 local Player = game.Players.LocalPlayer local event = Instance.new("RemoteEvent")
event.Parent = game.Workspace event.Name = "Purchase" event.OnServerEvent:connect(function() game:GetService("MarketplaceService"):PromptProductPurchase(Player,ID) end) |
|
|
| Report Abuse |
|
|
WoolHat
|
  |
| Joined: 19 May 2013 |
| Total Posts: 1873 |
|
|
| 29 Apr 2016 04:31 PM |
2 things: 1, you don't need to create the event in the script. You can have it in the workspace beforehand.
2, LocalPlayer does not work in a server script. Think localscript, local player. Server scripts have no idea of what LocalPlayer is. So you need to define the Player. Luckily, Player is the first argument when using remotevents/functions (When doing local>server).
Workspace script: local ID = 33929599 local event = Instance.new("RemoteEvent")
event.Parent = game.Workspace event.Name = "Purchase" event.OnServerEvent:connect(function(Player) game:GetService("MarketplaceService"):PromptProductPurchase(Player,ID) end)
|
|
|
| Report Abuse |
|
|
|
| 29 Apr 2016 04:42 PM |
| sweet it works, now how do I do the same thing, except with a games, not developer item this time?? |
|
|
| Report Abuse |
|
|
|
| 29 Apr 2016 04:45 PM |
| gamepass* and nvm i changed PromptProductPurchase, to PromptPurchase and it worked for the gamepass |
|
|
| Report Abuse |
|
|
|
| 29 Apr 2016 07:19 PM |
@tackykiller10000
No, that's not what I was saying. I was confused about why you couldn't use PromptProductPurchase in a local script, because I though I did, but I was actually using PromptPurchase. Sorry for confusing you. |
|
|
| Report Abuse |
|
|