Advertisement
qsenko1

a bit buggy Touchpad pet system

Sep 6th, 2021
6,228
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 6.64 KB | None | 0 0
  1. -- Client Side
  2. local Pets = game.ReplicatedStorage.Pets:GetDescendants()
  3. local TouchPads = game.Workspace:WaitForChild("ShopPlaceModels"):GetDescendants()
  4. local PetEvent = game.ReplicatedStorage.Remotes.PetEvent
  5. local GamepassPetEvent = game.ReplicatedStorage.Remotes.GamepassPetEvent
  6. local PremiumPetEvent = game.ReplicatedStorage.Remotes.PremiumPetEvent
  7. local player = game.Players.LocalPlayer
  8. local debounce = true
  9.  
  10. for i,gamepass in pairs(TouchPads) do  
  11.     if gamepass:IsA("Part") and gamepass.Name == "GamepassTouchPad" then               
  12.         gamepass.Touched:Connect(function()
  13.             if player and debounce then
  14.                 debounce = false                       
  15.                 local GamepassPetName = gamepass:WaitForChild("Value").Value
  16.                 local Gamepassid = gamepass:WaitForChild("id").Value
  17.                 print(GamepassPetName)
  18.                 print(Gamepassid)
  19.                 GamepassPetEvent:FireServer(GamepassPetName,Gamepassid)              
  20.                 for i,petprices in pairs(Pets) do          
  21.                     if petprices:IsA("Part") and petprices.Name == "PricePart" then
  22.                         -- Update the price text idk
  23.                     end
  24.                 end
  25.                 wait(1)
  26.                 debounce = true
  27.                 return
  28.             end
  29.         end)
  30.     end
  31. end
  32.  
  33. -- Server side
  34. local PetEvent = game.ReplicatedStorage.Remotes.PetEvent
  35. local GamepassPetEvent = game.ReplicatedStorage.Remotes.GamepassPetEvent
  36. local PremiumPetEvent = game.ReplicatedStorage.Remotes.PremiumPetEvent
  37. local ActualPets = game.ReplicatedStorage.Pets:GetChildren()
  38. local MarketplaceService = game:GetService("MarketplaceService")
  39. local Market
  40.  
  41. GamepassPetEvent.OnServerEvent:Connect(function(player,GamepassPetName,Gamepassid)
  42.     local Pets = player.Character:FindFirstChild("Frost Dragon") or player.Character:FindFirstChild("Hell Dragon") or player.Character:FindFirstChild("Shadow Dragon") or player.Character:FindFirstChild("Megavore") or player.Character:FindFirstChild("Eye of Cthulhu") or player.Character:FindFirstChild("Magma Dragon") or player.Character:FindFirstChild("Arctic Reindeer") or player.Character:FindFirstChild("Evil Unicorn") or player.Character:FindFirstChild("Gray Wolf") or player.Character:FindFirstChild("Dog") or player.Character:FindFirstChild("T-Rex") or player.Character:FindFirstChild("Otter") or player.Character:FindFirstChild("Scorpion") or player.Character:FindFirstChild("Alien Bee") or player.Character:FindFirstChild("Phoenix") or player.Character:FindFirstChild("Eye of Cthulhu")  
  43.     local ownsGamepass = game:GetService("MarketplaceService"):UserOwnsGamePassAsync(player.UserId,Gamepassid)
  44.     local success, errormessage = pcall(ownsGamepass);
  45.     --print(GamepassPetName)
  46.     --print(Gamepassid)
  47.     if player and not ownsGamepass then        
  48.         game:GetService("MarketplaceService"):PromptGamePassPurchase(player,Gamepassid)
  49.         local function gamepassPurchaseFinished(player,Gamepassid,wasPurchased)    
  50.             Market:Disconnect()
  51.             if wasPurchased == true then
  52.                 print("Purchased") 
  53.                 for i,pets in pairs(ActualPets) do
  54.                     print("hi")
  55.                     print(Gamepassid)
  56.                     print(GamepassPetName)
  57.                     if pets:IsA("Model") and pets.Name == GamepassPetName then
  58.                         local Pets = player.Character:FindFirstChild("Frost Dragon") or player.Character:FindFirstChild("Hell Dragon") or player.Character:FindFirstChild("Shadow Dragon") or player.Character:FindFirstChild("Megavore") or player.Character:FindFirstChild("Eye of Cthulhu") or player.Character:FindFirstChild("Magma Dragon") or player.Character:FindFirstChild("Arctic Reindeer") or player.Character:FindFirstChild("Evil Unicorn") or player.Character:FindFirstChild("Gray Wolf") or player.Character:FindFirstChild("Dog") or player.Character:FindFirstChild("T-Rex") or player.Character:FindFirstChild("Otter") or player.Character:FindFirstChild("Scorpion") or player.Character:FindFirstChild("Alien Bee") or player.Character:FindFirstChild("Phoenix") or player.Character:FindFirstChild("Eye of Cthulhu")  
  59.                         if Pets and player.Pets:FindFirstChild("PetsName").Value ~= "" then
  60.                             Pets:Destroy()
  61.                             player.Pets:FindFirstChild("PetsName").Value = ""  
  62.                             local pet = pets:Clone()
  63.                             pet.Parent = player.Character
  64.                             player.Pets:FindFirstChild("PetsName").Value = pets.Name
  65.                             --GamepassPetEvent:FireClient(player,GamepassPetName,Gamepassid)
  66.                             break
  67.                         else
  68.                             local pet = pets:Clone()
  69.                             pet.Parent = player.Character
  70.                             player.Pets:FindFirstChild("PetsName").Value = pets.Name
  71.                             --GamepassPetEvent:FireClient(player,GamepassPetName,Gamepassid)
  72.                             break
  73.                         end
  74.                     end    
  75.                 end
  76.             else       
  77.                 print("Canceled")
  78.                 return
  79.             end
  80.         end    
  81.         Market = MarketplaceService.PromptGamePassPurchaseFinished:Connect(gamepassPurchaseFinished)
  82.     end  
  83.    
  84.     if player and ownsGamepass then        
  85.         for i,pets in pairs(ActualPets) do
  86.             --print(pets.Name)
  87.             --  print(Name)
  88.             if pets:IsA("Model") and pets.Name == GamepassPetName then
  89.                 --      print("We own it") -- If we Own the gamepass
  90.                 local Pets = player.Character:FindFirstChild("Frost Dragon") or player.Character:FindFirstChild("Hell Dragon") or player.Character:FindFirstChild("Shadow Dragon") or player.Character:FindFirstChild("Megavore") or player.Character:FindFirstChild("Eye of Cthulhu") or player.Character:FindFirstChild("Magma Dragon") or player.Character:FindFirstChild("Arctic Reindeer") or player.Character:FindFirstChild("Evil Unicorn") or player.Character:FindFirstChild("Gray Wolf") or player.Character:FindFirstChild("Dog") or player.Character:FindFirstChild("T-Rex") or player.Character:FindFirstChild("Otter") or player.Character:FindFirstChild("Scorpion") or player.Character:FindFirstChild("Alien Bee") or player.Character:FindFirstChild("Phoenix") or player.Character:FindFirstChild("Eye of Cthulhu")  
  91.                 if Pets and player.Pets:FindFirstChild("PetsName").Value ~= GamepassPetName then
  92.                 --  print("idk")
  93.                     Pets:Destroy()
  94.                     player.Pets:FindFirstChild("PetsName").Value = ""  
  95.                     local pet = pets:Clone()
  96.                     pet.Parent = player.Character
  97.                     player.Pets:FindFirstChild("PetsName").Value = pets.Name
  98.                     GamepassPetEvent:FireClient(player,GamepassPetName,Gamepassid)
  99.                     break
  100.                 end
  101.                 if Pets and player.Pets:FindFirstChild("PetsName").Value == GamepassPetName and Pets.Name == GamepassPetName then
  102.                 --  print("idk")
  103.                     Pets:Destroy()
  104.                     player.Pets:FindFirstChild("PetsName").Value = ""  
  105.                     GamepassPetEvent:FireClient(player,GamepassPetName,Gamepassid)
  106.                     break
  107.                 end
  108.                 if not Pets and player.Pets:FindFirstChild("PetsName").Value == "" and pets.Name == GamepassPetName then
  109.                 --  print("idk")
  110.                     local pet = pets:Clone()
  111.                     pet.Parent = player.Character
  112.                     player.Pets:FindFirstChild("PetsName").Value = pets.Name
  113.                     GamepassPetEvent:FireClient(player,GamepassPetName,Gamepassid)
  114.                     break  
  115.                 end
  116.             end
  117.         end    
  118.     end
  119. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement