Advertisement
qsenko1

Gamepass touched giver without prints!!

Apr 28th, 2022
874
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.18 KB | None | 0 0
  1. local Players = game:GetService("Players")
  2. local MarkeplaceService = game:GetService("MarketplaceService")
  3. local ItemGivers = game.Workspace.CoilsModel.Model -- the model with all the touchpads
  4. local ItemLocation = game.ReplicatedStorage.GamepassItems -- the location of the tools in replicate storage
  5. local debounce = true
  6. local disconnectvalue
  7.  
  8. for i,v in pairs(ItemGivers:GetDescendants()) do   
  9.     if v:IsA("Part") and v.Name == "Giver" then
  10.         v.Touched:Connect(function(hit)            
  11.             local player = Players:GetPlayerFromCharacter(hit.Parent)
  12.             if player and debounce then
  13.                 debounce = false
  14.                 local GamepassId = v.Gamepass.Value -- an int value that is taken from the part thats touched
  15.                 local GamepassName = v.ItemName.Value -- a string value that is taken from the part thats touched
  16.                 local ownsGamepass = game:GetService("MarketplaceService"):UserOwnsGamePassAsync(player.UserId,GamepassId)
  17.                 if not ownsGamepass then
  18.                     local Purchase = game:GetService("MarketplaceService"):PromptGamePassPurchase(player,GamepassId)
  19.                     local function gamepassPurchaseFinished(player,GamepassId,wasPurchased)
  20.                         if wasPurchased == true and debounce then
  21.                             debounce = false
  22.                             local items1 = ItemLocation:FindFirstChild(GamepassName):Clone()
  23.                             items1.Parent = player.Backpack
  24.                             local items2 = ItemLocation:FindFirstChild(GamepassName):Clone()
  25.                             items2.Parent = player.StarterGear
  26.                             task.wait(1)
  27.                             disconnectvalue:Disconnect()
  28.                             debounce = true
  29.                             return
  30.                         else       
  31.                             return
  32.                         end
  33.                     end
  34.                    
  35.                     disconnectvalue = MarkeplaceService.PromptGamePassPurchaseFinished:Connect(gamepassPurchaseFinished)   
  36.                 end
  37.                
  38.                 if ownsGamepass then
  39.                     if player.Backpack:FindFirstChild(GamepassName) then
  40.                     player.Backpack:FindFirstChild(GamepassName):Destroy()
  41.                     player.StarterGear:FindFirstChild(GamepassName):Destroy()
  42.                     else
  43.                         local item1 = ItemLocation:FindFirstChild(GamepassName):Clone()
  44.                         item1.Parent = player.Backpack
  45.                         local item2 = ItemLocation:FindFirstChild(GamepassName):Clone()
  46.                         item2.Parent = player.StarterGear
  47.                     end
  48.                 end
  49.                 task.wait(1)
  50.                 debounce = true
  51.             end
  52.         end)
  53.     end
  54. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement