qsenko1

Petshop Prototype 2

Jul 18th, 2021
182
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 29.79 KB | None | 0 0
  1. --Local Script
  2. -- Made by qsenko29
  3. local RS = game:GetService("ReplicatedStorage") -- the actual Service in what we have all the Pets,Events stored and etc.
  4. local PetsFolder = RS.Pets
  5. local PetsPurchaseEvent = PetsFolder.PetEvents.PetsPurchase
  6. local PetsGamepassEvent = PetsFolder.PetEvents.PetGamepass
  7. local HiddenPetEvent = PetsFolder.PetEvents.HiddenPetEvent
  8. local MainFrame = script.Parent -- the frame that we will use to loop and get all objects,("instances") from!!!
  9. local debounce = true -- debounce is not recommended it can be just debounce that means its either true or false but i love setting it to something!!
  10. local player = game:GetService("Players").LocalPlayer -- thats a easy way of getting the local Player
  11. local PetValues = player.PetsFolder.Values:GetDescendants()      --:GetChildren()
  12. local BuyFrame = player.PlayerGui:WaitForChild("PetsPurchaseGui").BuyPet
  13. local BuyButton = player.PlayerGui:WaitForChild("PetsPurchaseGui").BuyPet.Buy
  14. local CancelButton = player.PlayerGui:WaitForChild("PetsPurchaseGui").BuyPet.Close
  15. local Pets = PetsFolder.ActualPets:GetChildren()
  16. local button1 -- gonna disconnect them later:P
  17. local button2  
  18. local button3
  19. --local previouspet = player.Character:FindFirstChild("Turtle") or player.Character:FindFirstChild("Bunny") or player.Character:FindFirstChild("Parrot") or player.Character:FindFirstChild("Piggy Bank") or player.Character:FindFirstChild("Mr.Crab") or player.Character:FindFirstChild("Puffer Fish") or player.Character:FindFirstChild("Hedgehog") or player.Character:FindFirstChild("CrocodilePal") or player.Character:FindFirstChild("King Frog") or player.Character:FindFirstChild("Kitty") or player.Character:FindFirstChild("Epic Duck") or player.Character:FindFirstChild("Octopus") or player.Character:FindFirstChild("Pet Rock") or player.Character:FindFirstChild("Sea Monster") or player.Character:FindFirstChild("Pikachu") or player.Character:FindFirstChild("OOF Spider") or player.Character:FindFirstChild("Pet Gojira") or player.Character:FindFirstChild("Scorpion") or player.Character:FindFirstChild("Scorpion") or player.Character:FindFirstChild("Hungry Shark") or player.Character:FindFirstChild("Annoying Orange") or player.Character:FindFirstChild("Evil Unicorn") or player.Character:FindFirstChild("Arctic Reindeer") or player.Character:FindFirstChild("Bird") or player.Character:FindFirstChild("Gray Wolf") or player.Character:FindFirstChild("Dog") or player.Character:FindFirstChild("Otter") or player.Character:FindFirstChild("Alien Bee") or player.Character:FindFirstChild("T-Rex") or player.Character:FindFirstChild("Phoenix") or player.Character:FindFirstChild("Hell Dragon") or player.Character:FindFirstChild("Dragon") or player.Character:FindFirstChild("DragonTest") or player.Character:FindFirstChild("Shadow Dragon") or player.Character:FindFirstChild("Megavore") or player.Character:FindFirstChild("Magma Dragon") or player.Character:FindFirstChild("Eye of Cthulhu")  
  20.  
  21. --print(Pets)
  22.  
  23. for i,v in pairs(MainFrame:GetDescendants())do
  24.     if v:IsA("ImageButton") and v.Name == "PetsButton" then    
  25.         for i,p in ipairs(PetValues)do 
  26.             button1 = v.MouseButton1Down:Connect(function(pet)         
  27.                 local function RunTest()                                           
  28.                     if p:IsA("BoolValue") and v:FindFirstChild("PetIndex").Value and v:FindFirstChild("PetIndex").Value == p.Name then  --  p.Name ==
  29.                         if debounce and player then    
  30.                             debounce = false   
  31.                             --local PetIsName = v:FindFirstChild("PetIndex").Value                                                                                                                                 
  32.                             if p.Value == false and v:FindFirstChild("PetIndex").Value and v:FindFirstChild("PetIndex").Value == p.Name and player.leaderstats.Coins.Value >= v.Price.Value then --and v:FindFirstChild("PetIndex").Value == p.Name-- and p[PetIsName] and p.Name == PetIsName 
  33.                                 local Frame = player:FindFirstChild("PlayerGui"):FindFirstChild("PetsPurchaseGui"):FindFirstChild("BuyPet")    
  34.                                 local FrameInfo = Frame:FindFirstChild("Desc")
  35.                                 local PetName = v:FindFirstChild("PetIndex").Value
  36.                                 local PetPrice = v:FindFirstChild("Price").Value
  37.                 --              print(v:FindFirstChild("PetIndex").Value .. " v - first if statement")         
  38.                 --              print(p.Name .. " p.Name - 1st if statement")      
  39.                 --              print(p.Value)         
  40.                                 FrameInfo.Text = "Are you Sure you want to buy this " .. PetName .. " for " .. PetPrice .. " Coins"        
  41.                                 Frame:TweenPosition(
  42.                                     UDim2.new(0.499, 0,0.494, 0),-- End Position       
  43.                                     "Out", -- Easing Direction
  44.                                     "Linear", -- Easing Style
  45.                                     .5 -- Time in Seconds
  46.                                 )  
  47.                                 Frame.Visible = true           
  48.                                 wait(.5)           
  49.                                 --      local thisbutton = v       
  50.                                 --      local newfunction = RunTest(thisbutton)
  51.                                 --      local something = "hi"
  52.                                 --BuyButton.MouseButton1Down:Connect(function(PetName,PetPrice)                
  53.                                 button2 = BuyButton.MouseButton1Down:Connect(function()                                                                                
  54.                                     -- damn it works!!!    
  55.                                     if debounce == false then          
  56.                                         --debounce = false                                                                                                     
  57.                                         local PetName = v:FindFirstChild("PetIndex").Value  -- you can comment this!!
  58.                                         --  print(thisbutton)
  59.                                         --  print(newfunction)
  60.                                         --RunTest()        
  61.                                     --  print(PetName)
  62.                                         --RunTest()    
  63.                                         --  print(PetPrice)
  64.                                         --   print(RunTest())
  65.                                         --  print(v:FindFirstChild("PetIndex").Value .. " v - first if statement")                         
  66.                                         --  print(p.Name .. " p.Name - 1st if statement")      
  67.                                         --   print(p.Value)            
  68.                                         --  end)
  69.                                         --  return PetName
  70.                                         PetsPurchaseEvent:FireServer(p,PetPrice)
  71.                                         BuyFrame:TweenPosition(
  72.                                             UDim2.new(0.499, 0,-1, 0),-- End Position      
  73.                                             "Out", -- Easing Direction
  74.                                             "Linear", -- Easing Style
  75.                                             .5 -- Time in Seconds
  76.                                         )      
  77.                                         wait(.5)
  78.                                         for i,pets in pairs(Pets)do
  79.                                             if pets:IsA("Model") then              
  80.                                                 --  print(pets.Name)   
  81.                                                 if p.Value == true then --not player.Character:FindFirstChild(pets.Name)               
  82.                                                     if player.PetsFolder:FindFirstChild("PetNameCheck").Value == pets.Name and player.Character:FindFirstChild(pets.Name) then
  83.                             --                          print("Pet was found in Character")
  84.                                                         v.PetPriceCheck.Text = "Equipped"
  85.                                                         for i,l in pairs(MainFrame:GetDescendants()) do
  86.                                                             if l:IsA("ImageButton") and l.Name == "PetsButton" then
  87.                                                                 if l:FindFirstChild("PetIndex").Value ~= player.PetsFolder:FindFirstChild("PetNameCheck").Value and player.PetsFolder:FindFirstChild("PetNameCheck").Value ~= ""  then -- and not v.Name
  88.                                                                     if l:FindFirstChild("PetPriceCheck").Text == "Equipped" then
  89.                                                                         l:FindFirstChild("PetPriceCheck").Text = "Owned"
  90.                             --                                          print("Name Change idk")
  91.                                                                     end
  92.                                                                 end
  93.                                                             end
  94.                                                         end
  95.                                                         break          
  96.                                                     end
  97.                                                     if player.PetsFolder:FindFirstChild("PetNameCheck").Value == "" and not player.Character:FindFirstChild(pets.Name) then
  98.                             --                          print("Pet was not found in Character")
  99.                                                         v.PetPriceCheck.Text = "Owned" 
  100.                                                         break
  101.                                                     end
  102.                                                 end        
  103.                                             end                
  104.                                         end                    
  105.                                        
  106.                                         button2:Disconnect()   
  107.                                         debounce = true    
  108.                                     end            
  109.                                 end)                   
  110.                                 --  debounce = true
  111.                                 --  return PetName         
  112.                             end    
  113.  
  114.                             if p.Value == false and v:FindFirstChild("PetIndex").Value and v:FindFirstChild("PetIndex").Value == p.Name and player.leaderstats.Coins.Value < v.Price.Value then -- and PetIsName                                 
  115.                                 v.PetPriceCheck.Text = "Not Enough Coins"
  116.                                 wait(0.5)
  117.                                 v.PetPriceCheck.Text = v.Price.Value .. " Coins" -- resets the price to its default per pet                                                                                
  118.                                 --     print(p.Name .. " p.Name - second if statement")    
  119.                                 --     print(v:FindFirstChild("PetIndex").Value .. " v - second if statement")     
  120.                                 --     print(p.Value)      
  121.                                 debounce = true    
  122.                             end                
  123.                             if p.Value == true then --and v:FindFirstChild("PetIndex").Value == p.Name and player.leaderstats.Coins.Value >= v.Price.Value or player.leaderstats.Coins.Value < v.Price.Value then                      
  124.                                 --     print(p.Name .. " p.Name - Third if statement")     
  125.                                 --     print(v:FindFirstChild("PetIndex").Value .. " v - Third if statement")  
  126.                                 --     print(p.Value)          
  127.                                 --v.PetPriceCheck.Text = "Owned"       
  128.                                 PetsPurchaseEvent:FireServer(p)
  129.                         --      print("We own the pet firing remote event")
  130.                                 for i,pets in pairs(Pets)do
  131.                                     if pets:IsA("Model") then              
  132.                                         --  print(pets.Name)
  133.                                         if p.Value == true then        
  134.                                            
  135.                                             if v.PetPriceCheck.Text == "Equipped" and player.PetsFolder:FindFirstChild("PetNameCheck").Value ~= "" and player.PetsFolder:FindFirstChild("PetNameCheck").Value == v.PetIndex.Value then --pets.Name
  136.                                 --              print("Pet was found in Character")
  137.                                                 v.PetPriceCheck.Text = "Owned" -- it was on Owned
  138.                                                 break          
  139.                                             end
  140.                                            
  141.                                         --[[    if v.PetPriceCheck.Text == "Equipped" and player.PetsFolder:FindFirstChild("PetNameCheck").Value ~= "" or player.PetsFolder:FindFirstChild("PetNameCheck").Value ~= v.PetIndex.Value then --pets.Name
  142.                                                 print("Pet was found in Character")
  143.                                                 v.PetPriceCheck.Text = "Equipped" -- it was on Owned
  144.                                                 -- we might need a loop in here
  145.                                                 break          
  146.                                             end--]]
  147.  
  148.                                             if v.PetPriceCheck.Text == "Owned" and player.PetsFolder:FindFirstChild("PetNameCheck").Value == "" or player.PetsFolder:FindFirstChild("PetNameCheck").Value == v.PetIndex.Value then             
  149.                                 --              print("Pet was not found in Character")
  150.                                                 v.PetPriceCheck.Text = "Equipped"  
  151.                                                 break
  152.                                             end    
  153.  
  154.                                             if v.PetPriceCheck.Text == "Owned" and player.PetsFolder:FindFirstChild("PetNameCheck").Value ~= "" or player.PetsFolder:FindFirstChild("PetNameCheck").Value ~= v.PetIndex.Value then             
  155.                     --                          print("Second Remove")         
  156.                     --                          print(v.Name)
  157.                                                 v.PetPriceCheck.Text = "Equipped"
  158.                                                 wait(.1)
  159.                                                 for i,z in pairs(MainFrame:GetDescendants()) do
  160.                                                     if z:IsA("ImageButton") and z.Name == "PetsButton" then
  161.                                                         if z:FindFirstChild("PetIndex").Value ~= player.PetsFolder:FindFirstChild("PetNameCheck").Value then
  162.                                                             if z.PetPriceCheck.Text == "Equipped" and player.PetsFolder:FindFirstChild("PetNameCheck").Value ~= z:FindFirstChild("PetIndex").Value then
  163.                                                                 z.PetPriceCheck.Text = "Owned"
  164.                                                             end
  165.                                                         end
  166.                                                     end
  167.                                                 end
  168.                                                 wait() 
  169.                                                 --[[for i,l in pairs(MainFrame:GetDescendants()) do
  170.                                                     if l:IsA("ImageButton") and l.Name == "PetsButton" then
  171.                                                         if l:FindFirstChild("PetIndex").Value ~= player.PetsFolder:FindFirstChild("PetNameCheck").Value and player.PetsFolder:FindFirstChild("PetNameCheck").Value ~= "" then -- and not v.Name
  172.                                                             if l:FindFirstChild("PetPriceCheck").Text == "Equipped" then
  173.                                                                 l:FindFirstChild("PetPriceCheck").Text = "Equipped"--Owned
  174.                                                                 print("Name Change idk")
  175.                                                                 --break
  176.                                                             end
  177.                                                         end
  178.                                                     end
  179.                                                 end--]]
  180.  
  181.                                                break
  182.                                             end
  183.  
  184.                                 --[[        if v.PetPriceCheck.Text == "Equipped" and player.PetsFolder:FindFirstChild("PetNameCheck").Value == "" then            
  185.                                             print("Second Equip")  
  186.                                             v.PetPriceCheck.Text = "Equipped"  
  187.                                             for i,l in pairs(MainFrame:GetDescendants()) do
  188.                                                 if l:IsA("ImageButton") and l.Name == "PetsButton" then
  189.                                                     if l:FindFirstChild("PetIndex").Value ~= player.PetsFolder:FindFirstChild("PetNameCheck").Value then
  190.                                                         if l:FindFirstChild("PetPriceCheck").Text == "Equipped" then
  191.                                                             l:FindFirstChild("PetPriceCheck").Text = "Owned"
  192.                                                             print("Name Change idk")
  193.                                                         end
  194.                                                     end
  195.                                                 end
  196.                                             end
  197.                                            
  198.                                             break
  199.                                         end
  200.                                     end
  201.                                 end                
  202.                             end --]]
  203.                                             --  v.PetPriceCheck.Text = v.Price.Value .. " Coins"
  204.                                         end
  205.                                     end                                        
  206.                                 end    
  207.                                 debounce = true        
  208.                             end        
  209.                             --  debounce = true    
  210.  
  211.                             --print("Making sure you work")                            
  212.                     wait() 
  213.                     --break
  214.                         end    
  215.                     end        
  216.                 end
  217.                 RunTest()
  218.                 button1:Disconnect()
  219.             end)
  220.         end
  221.     end
  222.  
  223.     if v:IsA("ImageButton") and v.Name == "PetsGamepassButton" then -- gamepass experiment stuff
  224.         --print("not my nigga") -- script will run when player is loaded basically the for loop:)
  225.         button3 = v.MouseButton1Down:Connect(function()
  226.             button3:Disconnect()
  227.             if debounce and player then        
  228.                 debounce = false
  229.             --  print("not my nigga")  
  230.                 local id = v:FindFirstChild("Gamepass Id").Value
  231.                 local Name = v:FindFirstChild("PetIndex").Value
  232.                 local TextPrice = v:FindFirstChild("PetPriceCheck").Text
  233.                 local ownsGamepass = game:GetService("MarketplaceService"):UserOwnsGamePassAsync(player.UserId,id)
  234.                 local success, errormessage = pcall(ownsGamepass);
  235.             --  print(id)  
  236.             --  print(Name)
  237.                 if ownsGamepass then
  238.                 --  print("he owns it")
  239.                     PetsGamepassEvent:FireServer(id,Name)
  240.                 else
  241.                 --  print("he doesnt own the gamepass!!")
  242.                     PetsGamepassEvent:FireServer(id,Name)
  243.                 end
  244.                 debounce = true
  245.               end
  246.            end)
  247.         end
  248.    
  249.     if v:IsA("ImageButton") and v.Name == "PetsHiddenButton" then -- hidden experiment stuff
  250.         --print("not my nigga") -- script will run when player is loaded basically the for loop:)
  251.         v.MouseButton1Down:Connect(function()
  252.             if debounce and player then        
  253.                 -- if stat bla bla = true then do this bam
  254.                 -- print("not my hidden nigga")                    
  255.             end
  256.         end)
  257.     end
  258. end
  259.  
  260. CancelButton.MouseButton1Down:Connect(function()
  261.     if not debounce and player then
  262.         --debounce = false
  263.         BuyFrame:TweenPosition(
  264.             UDim2.new(0.499, 0,-1, 0),-- End Position      
  265.             "Out", -- Easing Direction
  266.             "Linear", -- Easing Style
  267.             .5 -- Time in Seconds
  268.         )      
  269.         wait(.5)
  270.         button2:Disconnect()
  271.         BuyFrame.Visible = false   
  272.         debounce = true
  273.     end
  274. end)
  275.  
  276. --Server Pethandles
  277.  
  278. local DataStoreService = game:GetService("DataStoreService")
  279. local data = DataStoreService:GetDataStore("PetShop")
  280. local ReplicatedStorage = game:GetService("ReplicatedStorage")
  281. local MarketplaceService = game:GetService("MarketplaceService")
  282. local PetsFolder = ReplicatedStorage.Pets
  283. local PetsPurchaseEvent = PetsFolder.PetEvents.PetsPurchase
  284. local PetsGamepassEvent = PetsFolder.PetEvents.PetGamepass
  285. local Pets = PetsFolder.ActualPets:GetChildren()
  286. local Market
  287. local debounce = true
  288.  
  289. game.Players.PlayerAdded:Connect(function(player)
  290.     --Pets stuff
  291.     local PetsFolder = Instance.new("Folder",player); PetsFolder.Name = "PetsFolder"
  292.     local Pets = Instance.new("Folder",PetsFolder); Pets.Name = "Pets"
  293.     local PetsValues = Instance.new("Folder",PetsFolder); PetsValues.Name = "Values"
  294.     local PetNameCheck = Instance.new("StringValue",PetsFolder); PetNameCheck.Name = "PetNameCheck"
  295.     --Pets Values
  296.     local Turtle = Instance.new("BoolValue",PetsValues); Turtle.Name = "Turtle"
  297.     local Bunny = Instance.new("BoolValue",PetsValues); Bunny.Name = "Bunny"
  298.     local Parrot = Instance.new("BoolValue",PetsValues); Parrot.Name = "Parrot"
  299.     local PiggyBank = Instance.new("BoolValue",PetsValues); PiggyBank.Name = "Piggy Bank"
  300.     local MrCrab = Instance.new("BoolValue",PetsValues); MrCrab.Name = "Mr.Crab"
  301.     local PufferFish = Instance.new("BoolValue",PetsValues); PufferFish.Name = "Puffer Fish"
  302.     local Hedgehog = Instance.new("BoolValue",PetsValues); Hedgehog.Name = "Hedgehog"
  303.     local CrocodilePal = Instance.new("BoolValue",PetsValues); CrocodilePal.Name = "CrocodilePal"
  304.     local KingFrog = Instance.new("BoolValue",PetsValues); KingFrog.Name = "King Frog"
  305.     local Kitty = Instance.new("BoolValue",PetsValues); Kitty.Name = "Kitty"
  306.     local EpicDuck = Instance.new("BoolValue",PetsValues); EpicDuck.Name = "Epic Duck"
  307.     local Octopus = Instance.new("BoolValue",PetsValues); Octopus.Name = "Octopus"
  308.     local PetRock = Instance.new("BoolValue",PetsValues); PetRock.Name = "Pet Rock"
  309.     local SeaMonster = Instance.new("BoolValue",PetsValues); SeaMonster.Name = "Sea Monster"
  310.     local Pikachu = Instance.new("BoolValue",PetsValues); Pikachu.Name = "Pikachu"
  311.     local OOFSpider = Instance.new("BoolValue",PetsValues); OOFSpider.Name = "OOF Spider"
  312.     local PetGojira = Instance.new("BoolValue",PetsValues); PetGojira.Name = "Pet Gojira"
  313.     local Scorpion = Instance.new("BoolValue",PetsValues); Scorpion.Name = "Scorpion"
  314.     local HungryShark = Instance.new("BoolValue",PetsValues); HungryShark.Name = "Hungry Shark"
  315.     local AnnoyingOrange = Instance.new("BoolValue",PetsValues); AnnoyingOrange.Name = "Annoying Orange"
  316.     local EvilUnicorn = Instance.new("BoolValue",PetsValues); EvilUnicorn.Name = "Evil Unicorn"
  317.     local ArcticReindeer = Instance.new("BoolValue",PetsValues); ArcticReindeer.Name = "Arctic Reindeer"
  318.     local Bird = Instance.new("BoolValue",PetsValues); Bird.Name = "Bird"
  319.     local GrayWolf = Instance.new("BoolValue",PetsValues); GrayWolf.Name = "Gray Wolf"
  320.     local Dog = Instance.new("BoolValue",PetsValues); Dog.Name = "Dog"
  321.     local Otter = Instance.new("BoolValue",PetsValues); Otter.Name = "Otter"
  322.     local AlienBee = Instance.new("BoolValue",PetsValues); AlienBee.Name = "Alien Bee"
  323.     local TRex = Instance.new("BoolValue",PetsValues); TRex.Name = "T-Rex"
  324.     local Phoenix = Instance.new("BoolValue",PetsValues); Phoenix.Name = "Phoenix"
  325.     local HellDragon = Instance.new("BoolValue",PetsValues); HellDragon.Name = "Hell Dragon"
  326.     --Hidden Pet Value
  327.     local HiddenPetValue = Instance.new("BoolValue",PetsValues); HiddenPetValue.Name = "Eye of Cthulhu"
  328.    
  329.     player.CharacterAdded:Connect(function(Character)
  330.         local Pets = game:GetService("ReplicatedStorage").Pets.ActualPets:GetChildren()
  331.         for i,pets in pairs(Pets) do
  332.             if pets:IsA("Model") then
  333.                 if player.PetsFolder:FindFirstChild("PetNameCheck").Value == pets.Name then
  334.                     local pet = pets:Clone()
  335.                     pet.Parent = player.Character
  336.                     break
  337.                 end
  338.             end
  339.         end
  340.     end)
  341. end)
  342.  
  343. PetsPurchaseEvent.OnServerEvent:Connect(function(player,p,PetPrice)
  344.     local previouspet = player.Character:FindFirstChild("Turtle") or player.Character:FindFirstChild("Bunny") or player.Character:FindFirstChild("Parrot") or player.Character:FindFirstChild("Piggy Bank") or player.Character:FindFirstChild("Mr.Crab") or player.Character:FindFirstChild("Puffer Fish") or player.Character:FindFirstChild("Hedgehog") or player.Character:FindFirstChild("CrocodilePal") or player.Character:FindFirstChild("King Frog") or player.Character:FindFirstChild("Kitty") or player.Character:FindFirstChild("Epic Duck") or player.Character:FindFirstChild("Octopus") or player.Character:FindFirstChild("Pet Rock") or player.Character:FindFirstChild("Sea Monster") or player.Character:FindFirstChild("Pikachu") or player.Character:FindFirstChild("OOF Spider") or player.Character:FindFirstChild("Pet Gojira") or player.Character:FindFirstChild("Scorpion") or player.Character:FindFirstChild("Scorpion") or player.Character:FindFirstChild("Hungry Shark") or player.Character:FindFirstChild("Annoying Orange") or player.Character:FindFirstChild("Evil Unicorn") or player.Character:FindFirstChild("Arctic Reindeer") or player.Character:FindFirstChild("Bird") or player.Character:FindFirstChild("Gray Wolf") or player.Character:FindFirstChild("Dog") or player.Character:FindFirstChild("Otter") or player.Character:FindFirstChild("Alien Bee") or player.Character:FindFirstChild("T-Rex") or player.Character:FindFirstChild("Phoenix") or player.Character:FindFirstChild("Hell Dragon") or player.Character:FindFirstChild("Dragon") or player.Character:FindFirstChild("DragonTest") or player.Character:FindFirstChild("Shadow Dragon") or player.Character:FindFirstChild("Megavore") or player.Character:FindFirstChild("Magma Dragon") or player.Character:FindFirstChild("Eye of Cthulhu")  
  345. --  print("Received Server message")
  346. --  print(p)
  347. --  print(p.Name)
  348.     local Values = player.PetsFolder.Values
  349.     for i,v in pairs(Values:GetDescendants()) do
  350.         if v:IsA("BoolValue") then
  351.             --print(v.Name)
  352.             --print(v.Name == p.Name)
  353.             if v.Name == p.Name then
  354.             --  print("To the Next Step")
  355.                 --  print(v.Name == p)
  356.             --  print(v.Name)
  357.             --  print(v.Value)
  358.                 if v.Value == true then
  359.                 --  print(v.Name.." Owned")
  360.                     for i,pets in pairs(Pets) do
  361.                     --  print(pets.Name)
  362.                         if pets:IsA("Model") and p.Name == pets.Name then
  363.                     --      print(pets.Name)
  364.                     ----        print(v.Name.." v.Name")
  365.                     --      print(p.Name.." p.Name")
  366.                     --      print(pets.Name.." pets.Name")
  367.                             --local previouspet =   pets
  368.                             local previouspet = player.Character:FindFirstChild("Turtle") or player.Character:FindFirstChild("Bunny") or player.Character:FindFirstChild("Parrot") or player.Character:FindFirstChild("Piggy Bank") or player.Character:FindFirstChild("Mr.Crab") or player.Character:FindFirstChild("Puffer Fish") or player.Character:FindFirstChild("Hedgehog") or player.Character:FindFirstChild("CrocodilePal") or player.Character:FindFirstChild("King Frog") or player.Character:FindFirstChild("Kitty") or player.Character:FindFirstChild("Epic Duck") or player.Character:FindFirstChild("Octopus") or player.Character:FindFirstChild("Pet Rock") or player.Character:FindFirstChild("Sea Monster") or player.Character:FindFirstChild("Pikachu") or player.Character:FindFirstChild("OOF Spider") or player.Character:FindFirstChild("Pet Gojira") or player.Character:FindFirstChild("Scorpion") or player.Character:FindFirstChild("Scorpion") or player.Character:FindFirstChild("Hungry Shark") or player.Character:FindFirstChild("Annoying Orange") or player.Character:FindFirstChild("Evil Unicorn") or player.Character:FindFirstChild("Arctic Reindeer") or player.Character:FindFirstChild("Bird") or player.Character:FindFirstChild("Gray Wolf") or player.Character:FindFirstChild("Dog") or player.Character:FindFirstChild("Otter") or player.Character:FindFirstChild("Alien Bee") or player.Character:FindFirstChild("T-Rex") or player.Character:FindFirstChild("Phoenix") or player.Character:FindFirstChild("Hell Dragon") or player.Character:FindFirstChild("Dragon") or player.Character:FindFirstChild("DragonTest") or player.Character:FindFirstChild("Shadow Dragon") or player.Character:FindFirstChild("Megavore") or player.Character:FindFirstChild("Magma Dragon") or player.Character:FindFirstChild("Eye of Cthulhu")
  369.                             if previouspet and player.PetsFolder:FindFirstChild("PetNameCheck").Value ~= p.Name  then --or player.PetsTestFolder:FindFirstChild("PetNameCheck").Value ~= ""
  370.                     --          print("Pet owned and its not the same so we will destroy it")
  371.                     --          print("Destroy")
  372.                                 --local pet =   player.Character:FindFirstChild(pets.Name):Destroy()
  373.                                 --player.Character:FindFirstChild(pets.Name):Destroy()
  374.                                 previouspet:Destroy()
  375.                                 player.PetsFolder:FindFirstChild("PetNameCheck").Value = ""
  376.                                 local pet = pets:Clone()
  377.                                 pet.Parent = player.Character
  378.                                 player.PetsFolder:FindFirstChild("PetNameCheck").Value = pets.Name
  379.                                 break
  380.                             end
  381.                             if previouspet and player.PetsFolder:FindFirstChild("PetNameCheck").Value == p.Name and v.Name == p.Name then -- also need to fix or player.PetsFolder:FindFirstChild("PetNameCheck").Value ~= p.Name
  382.                     --          print("Pet owned and its in inventory so we will destroy it")
  383.                     --          print("Destroy")
  384.                                 --local pet =   player.Character:FindFirstChild(pets.Name):Destroy()
  385.                                 --player.Character:FindFirstChild(pets.Name):Destroy()
  386.                                 previouspet:Destroy()
  387.                                 player.PetsFolder:FindFirstChild("PetNameCheck").Value = ""
  388.                                 break
  389.                             end
  390.                             if not previouspet and player.PetsFolder:FindFirstChild("PetNameCheck").Value == "" and v.Name == p.Name and pets.Name == p.Name then -- something is fishy about this line of code
  391.                 --              print("Pet owned and its not in inventory so we will clone it")
  392.                 --              print("Clone")
  393.                                 local pet = pets:Clone()
  394.                                 pet.Parent = player.Character
  395.                                 player.PetsFolder:FindFirstChild("PetNameCheck").Value = pets.Name
  396.                                 break  
  397.                             end
  398.                     --[[        if previouspet and v.Name ~= p.Name and player.PetsFolder:FindFirstChild("PetNameCheck").Value ~= p.Name then -- something is fishy about this line of code
  399.                                 previouspet:Destroy()
  400.                                 player.PetsFolder:FindFirstChild("PetNameCheck").Value = ""
  401.                                 local pet = pets:Clone()
  402.                                 pet.Parent = player.Character
  403.                                 player.PetsFolder:FindFirstChild("PetNameCheck").Value = pets.Name
  404.                                 break  
  405.                             end--]]        
  406.                         end
  407.                     end
  408.                 else
  409.                 --  print(v.Name.." Not Owned")
  410.                 --  print(PetPrice)
  411.                     if player.leaderstats.Coins.Value >= PetPrice then 
  412.                     player.leaderstats.Coins.Value = player.leaderstats.Coins.Value - PetPrice
  413.                     v.Value = true 
  414.                         for i,pets in pairs(Pets) do
  415.                             if p.Name == pets.Name then
  416.                                 local previouspet = player.Character:FindFirstChild("Turtle") or player.Character:FindFirstChild("Bunny") or player.Character:FindFirstChild("Parrot") or player.Character:FindFirstChild("Piggy Bank") or player.Character:FindFirstChild("Mr.Crab") or player.Character:FindFirstChild("Puffer Fish") or player.Character:FindFirstChild("Hedgehog") or player.Character:FindFirstChild("CrocodilePal") or player.Character:FindFirstChild("King Frog") or player.Character:FindFirstChild("Kitty") or player.Character:FindFirstChild("Epic Duck") or player.Character:FindFirstChild("Octopus") or player.Character:FindFirstChild("Pet Rock") or player.Character:FindFirstChild("Sea Monster") or player.Character:FindFirstChild("Pikachu") or player.Character:FindFirstChild("OOF Spider") or player.Character:FindFirstChild("Pet Gojira") or player.Character:FindFirstChild("Scorpion") or player.Character:FindFirstChild("Scorpion") or player.Character:FindFirstChild("Hungry Shark") or player.Character:FindFirstChild("Annoying Orange") or player.Character:FindFirstChild("Evil Unicorn") or player.Character:FindFirstChild("Arctic Reindeer") or player.Character:FindFirstChild("Bird") or player.Character:FindFirstChild("Gray Wolf") or player.Character:FindFirstChild("Dog") or player.Character:FindFirstChild("Otter") or player.Character:FindFirstChild("Alien Bee") or player.Character:FindFirstChild("T-Rex") or player.Character:FindFirstChild("Phoenix") or player.Character:FindFirstChild("Hell Dragon") or player.Character:FindFirstChild("Dragon") or player.Character:FindFirstChild("DragonTest") or player.Character:FindFirstChild("Shadow Dragon") or player.Character:FindFirstChild("Megavore") or player.Character:FindFirstChild("Magma Dragon") or player.Character:FindFirstChild("Eye of Cthulhu")
  417.                                 if previouspet and player.PetsFolder:FindFirstChild("PetNameCheck").Value ~= "" then
  418.                             --  print("Checking Before Cloning")   
  419.                                 previouspet:Destroy()
  420.                                 player.PetsFolder:FindFirstChild("PetNameCheck").Value = ""
  421.                                 local pet = pets:Clone()
  422.                                 pet.Parent = player.Character
  423.                                 player.PetsFolder:FindFirstChild("PetNameCheck").Value = pets.Name
  424.                                 else   
  425.                         --      print("Cloning")
  426.                                 --print(pets)
  427.                                 local pet = pets:Clone()
  428.                                 pet.Parent = player.Character
  429.                                 player.PetsFolder:FindFirstChild("PetNameCheck").Value = pets.Name
  430.                                 end
  431.                             end
  432.                         end
  433.                     else
  434.                         print("Player Doesnt Have the Coin,Hes Poor")
  435.                     end
  436.                 end    
  437.             end
  438.         end
  439.     end
  440. end)
  441.  
  442. PetsGamepassEvent.OnServerEvent:Connect(function(player,id,Name)   
  443.     local previouspet = player.Character:FindFirstChild("Turtle") or player.Character:FindFirstChild("Bunny") or player.Character:FindFirstChild("Parrot") or player.Character:FindFirstChild("Piggy Bank") or player.Character:FindFirstChild("Mr.Crab") or player.Character:FindFirstChild("Puffer Fish") or player.Character:FindFirstChild("Hedgehog") or player.Character:FindFirstChild("CrocodilePal") or player.Character:FindFirstChild("King Frog") or player.Character:FindFirstChild("Kitty") or player.Character:FindFirstChild("Epic Duck") or player.Character:FindFirstChild("Octopus") or player.Character:FindFirstChild("Pet Rock") or player.Character:FindFirstChild("Sea Monster") or player.Character:FindFirstChild("Pikachu") or player.Character:FindFirstChild("OOF Spider") or player.Character:FindFirstChild("Pet Gojira") or player.Character:FindFirstChild("Scorpion") or player.Character:FindFirstChild("Scorpion") or player.Character:FindFirstChild("Hungry Shark") or player.Character:FindFirstChild("Annoying Orange") or player.Character:FindFirstChild("Evil Unicorn") or player.Character:FindFirstChild("Arctic Reindeer") or player.Character:FindFirstChild("Bird") or player.Character:FindFirstChild("Gray Wolf") or player.Character:FindFirstChild("Dog") or player.Character:FindFirstChild("Otter") or player.Character:FindFirstChild("Alien Bee") or player.Character:FindFirstChild("T-Rex") or player.Character:FindFirstChild("Phoenix") or player.Character:FindFirstChild("Hell Dragon") or player.Character:FindFirstChild("Dragon") or player.Character:FindFirstChild("DragonTest") or player.Character:FindFirstChild("Shadow Dragon") or player.Character:FindFirstChild("Megavore") or player.Character:FindFirstChild("Magma Dragon") or player.Character:FindFirstChild("Eye of Cthulhu")
  444.     local ownsGamepass = game:GetService("MarketplaceService"):UserOwnsGamePassAsync(player.UserId,id)
  445.     local success, errormessage = pcall(ownsGamepass);
  446.     --print(player)
  447.     --print(id)
  448.     --print(Name)  
  449.     if player and not ownsGamepass then        
  450.         game:GetService("MarketplaceService"):PromptGamePassPurchase(player,id)
  451.         print(Name)
  452.         local function gamepassPurchaseFinished(player,id,wasPurchased)    
  453.             Market:Disconnect()
  454.             if wasPurchased == true then
  455.                 print("Purchased") 
  456.                 print(id)              
  457.             else
  458.                 print("Canceled")
  459.                 print(id)
  460.             end
  461.         end    
  462.         Market = MarketplaceService.PromptGamePassPurchaseFinished:Connect(gamepassPurchaseFinished)
  463.     end
  464.    
  465.     if player and ownsGamepass then        
  466.         print("We own it")
  467.     end
  468. end)
Add Comment
Please, Sign In to add comment