Advertisement
qsenko1

Annoying thing

Sep 9th, 2021
1,075
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.79 KB | None | 0 0
  1. local Players = game.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 Items = {"GravityCoil","AccelerationCoil","BoomBox","FlyingCarpet","FlyingCloud"} -- a random table test
  6.  
  7. local debounce = true
  8.  
  9. for i,v in pairs(ItemGivers:GetDescendants()) do   
  10.     --print(v)
  11.     if v:IsA("Part") and v.Name == "Giver" then
  12.         print(v)
  13.         v.Touched:Connect(function(hit)            
  14.             local player = Players:GetPlayerFromCharacter(hit.Parent)
  15.             if player and debounce then
  16.                 debounce = false
  17.                 local GamepassId = v.Gamepass.Value
  18.                 local GamepassName = v.ItemName.Value
  19.                 local ownsGamepass = game:GetService("MarketplaceService"):UserOwnsGamePassAsync(player.UserId,GamepassId)
  20.                 print(player)
  21.                 print(GamepassId)
  22.                 print(GamepassName)
  23.                 print(ownsGamepass)
  24.  
  25.                 if not ownsGamepass then
  26.                     local Purchase = game:GetService("MarketplaceService"):PromptGamePassPurchase(player,GamepassId)
  27.                     --print(Purchase)
  28.                 end
  29.  
  30.                 if ownsGamepass then
  31.                     print("owned")
  32.                     for i,items in pairs(player.Backpack:GetChildren()) do
  33.                         print(items.Name)
  34.                         if items:IsA("Tool") and player.Backpack:FindFirstChild(items) and items.Name == GamepassName then
  35.                             print(GamepassName)
  36.                             print(items)                           
  37.                             for i,items2 in pairs(player.StarterGear:GetChildren()) do
  38.                                 if items2:IsA("Tool") and items2.Name == items.Name then
  39.                                     print(items2)
  40.                                     items:Destroy()
  41.                                     items2:Destroy()
  42.                                     break
  43.                                 end
  44.                             end
  45.                         end
  46.                        
  47.                         if items:IsA("Tool") and not player.Backpack:FindFirstChild(items) then  
  48.                             print("hi")
  49.                             items = GamepassName
  50.                             print(items)
  51.                             for i,itemsinstorage in pairs(ItemLocation:GetChildren()) do
  52.                                 if itemsinstorage.Name == items then
  53.                                     print(itemsinstorage)
  54.                                     local item1 = itemsinstorage:Clone()
  55.                                     item1.Parent = player.Backpack
  56.                                     local item2 = itemsinstorage:Clone()
  57.                                     item2.Parent = player.StarterGear
  58.                                 end
  59.                             end
  60.                         end
  61.                     --[[elseif player.Backpack:FindFirstChild(Items) ~= GamepassName then
  62.                             print("hi")
  63.                             for i,itemsinstorage in pairs(ItemLocation:GetChildren()) do
  64.                                 print(itemsinstorage)
  65.                                 itemsinstorage = GamepassName
  66.                                 print(itemsinstorage)
  67.                                
  68.                                 if itemsinstorage == GamepassName then
  69.                                     print(itemsinstorage)
  70.                                     local item1 = itemsinstorage:Clone()
  71.                                     item1.Parent = player.Backpack
  72.                                 end
  73.                                 break
  74.                             end
  75.                             break  
  76.                         end
  77.                         break
  78.                     end
  79.                 end
  80.                 wait(1)
  81.                 debounce = true
  82.             end
  83.         end)
  84.     end
  85. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement