generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripters
Home Search
 

Re: Prompt Purchase: Why Won't This Code Work??

Previous Thread :: Next Thread 
tackykiller10000 is not online. tackykiller10000
Joined: 31 May 2010
Total Posts: 175
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 is online. 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 is not online. Salinas23
Joined: 28 Dec 2008
Total Posts: 37141
29 Apr 2016 07:19 AM
yup needs to be a server script
Report Abuse
KeiRoMultiverse is not online. KeiRoMultiverse
Joined: 16 Aug 2013
Total Posts: 1896
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 is not online. Salinas23
Joined: 28 Dec 2008
Total Posts: 37141
29 Apr 2016 08:26 AM
nope you didnt

needs to be server script
Report Abuse
KeiRoMultiverse is not online. KeiRoMultiverse
Joined: 16 Aug 2013
Total Posts: 1896
29 Apr 2016 08:35 AM
Ah, never mind, my game did PromptPurchase, not PromptProductPurchase.
Report Abuse
tackykiller10000 is not online. tackykiller10000
Joined: 31 May 2010
Total Posts: 175
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
tackykiller10000 is not online. tackykiller10000
Joined: 31 May 2010
Total Posts: 175
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
Skyrospect is not online. Skyrospect
Joined: 03 Jul 2013
Total Posts: 581
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
ExtremeBuilder15 is not online. ExtremeBuilder15
Joined: 01 May 2012
Total Posts: 3176
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
tackykiller10000 is not online. tackykiller10000
Joined: 31 May 2010
Total Posts: 175
29 Apr 2016 02:14 PM
How would I make it only prompt the person who clicked it?
Report Abuse
RecurringNightmare is not online. RecurringNightmare
Joined: 05 Jul 2012
Total Posts: 15336
29 Apr 2016 02:28 PM
it needs to be a localscripts..promptpurchase for gamepasses, promptproductpurchase for dev products


Report Abuse
tackykiller10000 is not online. tackykiller10000
Joined: 31 May 2010
Total Posts: 175
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 is online. 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
tackykiller10000 is not online. tackykiller10000
Joined: 31 May 2010
Total Posts: 175
29 Apr 2016 04:15 PM
and how exactly would I do that? I'm not familiar with remote functions.
Report Abuse
tackykiller10000 is not online. tackykiller10000
Joined: 31 May 2010
Total Posts: 175
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 is online. 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
tackykiller10000 is not online. tackykiller10000
Joined: 31 May 2010
Total Posts: 175
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
tackykiller10000 is not online. tackykiller10000
Joined: 31 May 2010
Total Posts: 175
29 Apr 2016 04:45 PM
gamepass* and nvm i changed PromptProductPurchase, to PromptPurchase and it worked for the gamepass
Report Abuse
KeiRoMultiverse is not online. KeiRoMultiverse
Joined: 16 Aug 2013
Total Posts: 1896
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
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image