Advertisement
qsenko1

gamepass giver

Sep 10th, 2021
1,810
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.21 KB | None | 0 0
  1. local Players = game:GetService("Players")
  2. local debounce = true
  3. local debounce2 = true
  4. local TouchPart = script.Parent
  5. local MarketplaceService = game:GetService("MarketplaceService")
  6. local Market
  7. local Gamepassid = 22076513
  8.  
  9. function onTouched(hit)
  10.     if hit.Parent:findFirstChild("Humanoid") and debounce then         
  11.         local player = Players:GetPlayerFromCharacter(hit.Parent)
  12.         local ownsGamepass = game:GetService("MarketplaceService"):UserOwnsGamePassAsync(player.UserId,22076513)
  13.         if player and not ownsGamepass then
  14.         debounce = false           
  15.         game:GetService("MarketplaceService"):PromptGamePassPurchase(player,22076513)
  16.         wait(1)
  17.         debounce = true
  18.         end
  19.        
  20.         local Radio = player.Backpack:FindFirstChild("BoomBox")
  21.         if ownsGamepass and not Radio then
  22.             debounce = false
  23.            
  24.             local RadioBox = game:GetService("ReplicatedStorage").GamepassItems:FindFirstChild("BoomBox"):Clone()
  25.             local RadioBox2 = game:GetService("ReplicatedStorage").GamepassItems:FindFirstChild("BoomBox"):Clone()
  26.  
  27.             RadioBox.Parent = player.Backpack  
  28.             RadioBox2.Parent = player.StarterGear
  29.             wait(1.5)
  30.             debounce = true
  31.             return
  32.         end
  33.        
  34.         if ownsGamepass and player.Backpack:FindFirstChild("BoomBox") then
  35.             local humanoid = player.Character:FindFirstChildOfClass("Humanoid")
  36.             if humanoid then
  37.                 debounce = false
  38.                 humanoid:UnequipTools()
  39.                 player.Backpack:FindFirstChild("BoomBox"):Destroy()
  40.                 player.StarterGear:FindFirstChild("BoomBox"):Destroy() 
  41.                 wait(1.5)
  42.                 debounce = true
  43.                 return
  44.             end            
  45.         end        
  46.     end
  47.    
  48.     local function gamepassPurchaseFinished(player,Gamepassid,wasPurchased)
  49.         Market:Disconnect()
  50.         if wasPurchased == true and debounce2 then
  51.             debounce2 = false
  52.             local RadioBox = game:GetService("ReplicatedStorage").GamepassItems:FindFirstChild("BoomBox"):Clone()
  53.             local RadioBox2 = game:GetService("ReplicatedStorage").GamepassItems:FindFirstChild("BoomBox"):Clone()
  54.             RadioBox.Parent = player.Backpack  
  55.             RadioBox2.Parent = player.StarterGear
  56.             wait(1)
  57.             debounce2 = true
  58.             return
  59.         else       
  60.             print("Canceled")
  61.             return
  62.         end
  63.     end
  64.     Market = MarketplaceService.PromptGamePassPurchaseFinished:Connect(gamepassPurchaseFinished)
  65. end
  66.  
  67. TouchPart.Touched:connect(onTouched)
  68.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement