Advertisement
Guest User

Untitled

a guest
Jun 22nd, 2018
137
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.26 KB | None | 0 0
  1. Step 1: create screen GUI, name it Shop
  2. Step 2: insert frame inside the GUI, name it Shop Frame
  3. Step 3: insert text button inside Shop frame and insert a local script
  4. Step 4: the local script is:
  5. ----------------------------------------------------------------------------------------------
  6. local bloxyColaId = 1352531547 -- Put the "ID" of Your "Item" that you want to sell.
  7. local player = game.Players.LocalPlayer
  8.  
  9. function onClick()
  10. Game:GetService("MarketplaceService"):PromptPurchase(player, bloxyColaId)
  11. end
  12.  
  13. script.Parent.MouseButton1Click:connect(onClick)
  14. ---------------------------------------------------------------------------------------------------
  15. Step 5:insert script in workspace
  16. Step 5: in the script type
  17.  
  18. --------------------
  19. --| WaitForChild |--
  20. --------------------
  21.  
  22. -- Waits for parent.child to exist, then returns it
  23. local function WaitForChild(parent, childName)
  24. assert(parent, "ERROR: WaitForChild: parent is nil")
  25. while not parent:FindFirstChild(childName) do parent.ChildAdded:wait() end
  26. return parent[childName]
  27. end
  28.  
  29. -----------------
  30. --| Variables |--
  31. -----------------
  32.  
  33. local GamePassService = Game:GetService('GamePassService')
  34. local PlayersService = Game:GetService('Players')
  35. local InsertService = Game:GetService('InsertService')
  36. local LightingService = Game:GetService('Lighting') --TODO: Use new data store service once that exists
  37.  
  38. local GamePassIdObject = WaitForChild(script, 'GamePassId')
  39. local ToolAssetsToLoad = WaitForChild(script, 'ToolAssetsToLoad')
  40.  
  41. local AdminTools = LightingService:FindFirstChild('AdminTools')
  42.  
  43. -----------------
  44. --| Functions |--
  45. -----------------
  46.  
  47. -- Makes copies of all the admin tools and puts them in target
  48. local function CloneAdminTools(target)
  49. for _, tool in pairs(AdminTools:GetChildren()) do
  50. local toolClone = tool:Clone()
  51. toolClone.Parent = target
  52. end
  53. end
  54.  
  55. -- When a player with the game pass joins, give them the admin tools
  56. local function OnPlayerAdded(player)
  57. if GamePassService:PlayerHasPass(player, GamePassIdObject.Value) then
  58. local starterGear = WaitForChild(player, 'StarterGear')
  59. CloneAdminTools(starterGear)
  60. if player.Character then -- They've already loaded and won't get their StarterGear until next spawn
  61. local backpack = WaitForChild(player, 'Backpack')
  62. CloneAdminTools(backpack)
  63. end
  64. end
  65. end
  66.  
  67. --------------------
  68. --| Script Logic |--
  69. --------------------
  70.  
  71. -- Create AdminTools if it doesn't exist
  72. if not AdminTools then
  73. AdminTools = Instance.new('Model')
  74. AdminTools.Name = 'AdminTools'
  75.  
  76. -- Load all of the assets in ToolAssetsToLoad and put them in AdminTools
  77. for _, intObject in pairs(ToolAssetsToLoad:GetChildren()) do
  78. if intObject and intObject:IsA('IntValue') and intObject.Value then
  79. local assetModel = InsertService:LoadAsset(intObject.Value)
  80. if assetModel then
  81. local asset = assetModel:GetChildren()[1]
  82. if asset then
  83. asset.Parent = AdminTools
  84. end
  85. end
  86. end
  87. end
  88.  
  89. AdminTools.Parent = LightingService
  90. end
  91.  
  92. PlayersService.PlayerAdded:connect(OnPlayerAdded)
  93.  
  94. Step 6: insert an int. value in the script, name it gamepass id
  95. Step 7: insert a model in the script
  96. Step 8: insert a int. value in the model
  97. Step 9: tell me when you are done and i teach u how to add gamepass and item :)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement