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: Whats wrong with this (Anonymous Function)

Previous Thread :: Next Thread 
Baya is not online. Baya
Joined: 16 Feb 2009
Total Posts: 12044
31 Oct 2016 02:28 PM

local ID = 516086074
script.Parent.Touched:connect(function()
game:GetService("MarketplaceService"):PromptPurchase(ITEM_ID)
end)






Report Abuse
expoundings is online. expoundings
Joined: 02 Feb 2013
Total Posts: 2359
31 Oct 2016 02:36 PM
lol
Report Abuse
Baya is not online. Baya
Joined: 16 Feb 2009
Total Posts: 12044
31 Oct 2016 02:47 PM
I don't see anything which is amusing.


Report Abuse
while_loop is not online. while_loop
Joined: 13 Aug 2016
Total Posts: 55
31 Oct 2016 02:51 PM
You have to give the player as the first argument.

You can get the player by using the :GetPlayerFromCharacter method on Players, giving the parent of the part that touched the scripts parent.

Also, you may want to check to see if the player already owns the item before prompting them to purchase it.

local MarketplaceService = game:GetService("MarketplaceService")

local Id = 516086074

script.Parent.Touched:connect(function(Hit)
local Player = game:GetService("Players"):GetPlayerFromCharacter(Hit.Parent)
if Player and not MarketplaceService:PlayerOwnsAsset(Player, Id) then
MarketplaceService:PromptPurchase(Player, Id)
end
end)


Report Abuse
Happywalker is not online. Happywalker
Joined: 05 Mar 2010
Total Posts: 3672
31 Oct 2016 02:51 PM
it does not know who to prompt it to


Report Abuse
Lord_Oscar is online. Lord_Oscar
Joined: 15 Nov 2009
Total Posts: 17662
31 Oct 2016 02:52 PM
local ID = 516086074

script.Parent.Touched:connect(function(hit)
if hit and hit.Parent and hit.Parent:FindFirstChild("Humanoid") then
local player = game.Players:GetPlayerFromCharacter(hit.Parent)
game:GetService("MarketplaceService"):PromptPurchase(player,ID)
end
end)



^
that should work


Report Abuse
Baya is not online. Baya
Joined: 16 Feb 2009
Total Posts: 12044
31 Oct 2016 02:54 PM
More confusing than I thought it would be, thanks guys appreciated a lot!

Apart from the first guy.




Report Abuse
Happywalker is not online. Happywalker
Joined: 05 Mar 2010
Total Posts: 3672
31 Oct 2016 02:54 PM
lol when this is 'complicated'


Report Abuse
Crimsonal is not online. Crimsonal
Joined: 23 Apr 2011
Total Posts: 1795
31 Oct 2016 03:44 PM
> local ID = 516086074
> game:GetService("MarketplaceService"):PromptPurchase(ITEM_ID)

> ITEM_ID
> ID
uhhhhhhhhhhh,,,,,,,,,,,,,,
Report Abuse
Crimsonal is not online. Crimsonal
Joined: 23 Apr 2011
Total Posts: 1795
31 Oct 2016 03:47 PM
btw PromptPurchase() uses the playerId as the first argument and the ItemId as the second

MarketplaceService:PromptPurchase(PLAYER_ID, ITEM_ID);
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