Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Step 1: create screen GUI, name it Shop
- Step 2: insert frame inside the GUI, name it Shop Frame
- Step 3: insert text button inside Shop frame and insert a local script
- Step 4: the local script is:
- ----------------------------------------------------------------------------------------------
- local bloxyColaId = 1352531547 -- Put the "ID" of Your "Item" that you want to sell.
- local player = game.Players.LocalPlayer
- function onClick()
- Game:GetService("MarketplaceService"):PromptPurchase(player, bloxyColaId)
- end
- script.Parent.MouseButton1Click:connect(onClick)
- ---------------------------------------------------------------------------------------------------
- Step 5:insert script in workspace
- Step 5: in the script type
- --------------------
- --| WaitForChild |--
- --------------------
- -- Waits for parent.child to exist, then returns it
- local function WaitForChild(parent, childName)
- assert(parent, "ERROR: WaitForChild: parent is nil")
- while not parent:FindFirstChild(childName) do parent.ChildAdded:wait() end
- return parent[childName]
- end
- -----------------
- --| Variables |--
- -----------------
- local GamePassService = Game:GetService('GamePassService')
- local PlayersService = Game:GetService('Players')
- local InsertService = Game:GetService('InsertService')
- local LightingService = Game:GetService('Lighting') --TODO: Use new data store service once that exists
- local GamePassIdObject = WaitForChild(script, 'GamePassId')
- local ToolAssetsToLoad = WaitForChild(script, 'ToolAssetsToLoad')
- local AdminTools = LightingService:FindFirstChild('AdminTools')
- -----------------
- --| Functions |--
- -----------------
- -- Makes copies of all the admin tools and puts them in target
- local function CloneAdminTools(target)
- for _, tool in pairs(AdminTools:GetChildren()) do
- local toolClone = tool:Clone()
- toolClone.Parent = target
- end
- end
- -- When a player with the game pass joins, give them the admin tools
- local function OnPlayerAdded(player)
- if GamePassService:PlayerHasPass(player, GamePassIdObject.Value) then
- local starterGear = WaitForChild(player, 'StarterGear')
- CloneAdminTools(starterGear)
- if player.Character then -- They've already loaded and won't get their StarterGear until next spawn
- local backpack = WaitForChild(player, 'Backpack')
- CloneAdminTools(backpack)
- end
- end
- end
- --------------------
- --| Script Logic |--
- --------------------
- -- Create AdminTools if it doesn't exist
- if not AdminTools then
- AdminTools = Instance.new('Model')
- AdminTools.Name = 'AdminTools'
- -- Load all of the assets in ToolAssetsToLoad and put them in AdminTools
- for _, intObject in pairs(ToolAssetsToLoad:GetChildren()) do
- if intObject and intObject:IsA('IntValue') and intObject.Value then
- local assetModel = InsertService:LoadAsset(intObject.Value)
- if assetModel then
- local asset = assetModel:GetChildren()[1]
- if asset then
- asset.Parent = AdminTools
- end
- end
- end
- end
- AdminTools.Parent = LightingService
- end
- PlayersService.PlayerAdded:connect(OnPlayerAdded)
- Step 6: insert an int. value in the script, name it gamepass id
- Step 7: insert a model in the script
- Step 8: insert a int. value in the model
- 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