Advertisement
qsenko1

Item Gamepass Touched Giver

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