qsenko1

PetShop System with Comments!!

Jul 26th, 2021
204
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 46.39 KB | None | 0 0
  1. -- Made by qsenko29
  2. -- ClientSide Script
  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.  
  20. --print(Pets)
  21.  
  22. for i,petCoins in pairs(MainFrame:GetDescendants()) do
  23.     if petCoins:IsA("ImageButton") and petCoins.Name == "PetsButton" then
  24.         for i,Values in pairs(PetValues) do
  25.             if Values:IsA("BoolValue") and Values.Value == true and petCoins.PetIndex.Value == Values.Name then
  26.                 if petCoins.PetIndex.Value == Values.Name and player.PetsFolder:FindFirstChild("PetNameCheck").Value == Values.Name then
  27.                 petCoins:FindFirstChild("PetPriceCheck").Text = "Equipped"
  28.                 print(Values.Name.. " Equipped")
  29.                 elseif petCoins.PetIndex.Value == Values.Name and player.PetsFolder:FindFirstChild("PetNameCheck").Value == "" or player.PetsFolder:FindFirstChild("PetNameCheck").Value ~= Values.Name then
  30.                 petCoins.PetPriceCheck.Text = "Owned"
  31.                 print(Values.Name.. " Owned")
  32.                 elseif Values:IsA("BoolValue") and Values.Value == false then
  33.                     if petCoins.PetIndex.Value == Values.Name then
  34.                        petCoins.PetPriceCheck.Text = petCoins.PetPriceCheck.Text
  35.                   break
  36.                end     
  37.             end
  38.          end
  39.       end
  40.    end
  41. end
  42.  
  43. for i,gamepass in pairs(MainFrame:GetDescendants()) do
  44.     if gamepass:IsA("ImageButton") and gamepass.Name == "PetsGamepassButton" then
  45.         if gamepass:FindFirstChild("Gamepass").Value then
  46.             local id = gamepass.Gamepass.Value
  47.             local ownsGamepass = game:GetService("MarketplaceService"):UserOwnsGamePassAsync(player.UserId,id)
  48.            
  49.             if ownsGamepass and player.PetsFolder:FindFirstChild("PetNameCheck").Value ~= gamepass.PetIndex.Value then
  50.                 gamepass.PetPriceCheck.Text = "Owned"
  51.                 print("Owned") 
  52.             else
  53.                 gamepass.PetPriceCheck.Text = gamepass.PetPriceCheck.Text  
  54.             end
  55.            
  56.             if ownsGamepass and player.PetsFolder:FindFirstChild("PetNameCheck").Value == gamepass.PetIndex.Value then
  57.                 gamepass.PetPriceCheck.Text = "Equipped"
  58.                 print("Equipped")
  59.             else
  60.                 gamepass.PetPriceCheck.Text = gamepass.PetPriceCheck.Text  
  61.             end
  62.            
  63.         end
  64.     end
  65. end
  66.  
  67. for i,v in pairs(MainFrame:GetDescendants())do
  68.     if v:IsA("ImageButton") and v.Name == "PetsButton" then    
  69.         for i,p in ipairs(PetValues)do 
  70.             button1 = v.MouseButton1Down:Connect(function(pet)         
  71.                 local function RunTest()                                           
  72.                     if p:IsA("BoolValue") and v:FindFirstChild("PetIndex").Value and v:FindFirstChild("PetIndex").Value == p.Name then  --  p.Name ==
  73.                         if debounce and player then    
  74.                             debounce = false   
  75.                             --local PetIsName = v:FindFirstChild("PetIndex").Value                                                                                                                                 
  76.                             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 
  77.                                 local Frame = player:FindFirstChild("PlayerGui"):FindFirstChild("PetsPurchaseGui"):FindFirstChild("BuyPet")    
  78.                                 local FrameInfo = Frame:FindFirstChild("Desc")
  79.                                 local PetName = v:FindFirstChild("PetIndex").Value
  80.                                 local PetPrice = v:FindFirstChild("Price").Value
  81.                 --              print(v:FindFirstChild("PetIndex").Value .. " v - first if statement")         
  82.                 --              print(p.Name .. " p.Name - 1st if statement")      
  83.                 --              print(p.Value)         
  84.                                 FrameInfo.Text = "Are you Sure you want to buy this " .. PetName .. " for " .. PetPrice .. " Coins"        
  85.                                 Frame:TweenPosition(
  86.                                     UDim2.new(0.499, 0,0.494, 0),-- End Position       
  87.                                     "Out", -- Easing Direction
  88.                                     "Linear", -- Easing Style
  89.                                     .5 -- Time in Seconds
  90.                                 )  
  91.                                 Frame.Visible = true           
  92.                                 wait(.5)           
  93.                                 --      local thisbutton = v       
  94.                                 --      local newfunction = RunTest(thisbutton)
  95.                                 --      local something = "hi"
  96.                                 --BuyButton.MouseButton1Down:Connect(function(PetName,PetPrice)                
  97.                                 button2 = BuyButton.MouseButton1Down:Connect(function()                                                                                
  98.                                     -- damn it works!!!    
  99.                                     if debounce == false then          
  100.                                         --debounce = false                                                                                                     
  101.                                         local PetName = v:FindFirstChild("PetIndex").Value  -- you can comment this!!
  102.                                         --  print(thisbutton)
  103.                                         --  print(newfunction)
  104.                                         --RunTest()        
  105.                                     --  print(PetName)
  106.                                         --RunTest()    
  107.                                         --  print(PetPrice)
  108.                                         --   print(RunTest())
  109.                                         --  print(v:FindFirstChild("PetIndex").Value .. " v - first if statement")                         
  110.                                         --  print(p.Name .. " p.Name - 1st if statement")      
  111.                                         --   print(p.Value)            
  112.                                         --  end)
  113.                                         --  return PetName
  114.                                         PetsPurchaseEvent:FireServer(p,PetPrice)
  115.                                         BuyFrame:TweenPosition(
  116.                                             UDim2.new(0.499, 0,-1, 0),-- End Position      
  117.                                             "Out", -- Easing Direction
  118.                                             "Linear", -- Easing Style
  119.                                             .5 -- Time in Seconds
  120.                                         )      
  121.                                         wait(.5)
  122.                                         for i,pets in pairs(Pets)do
  123.                                             if pets:IsA("Model") then              
  124.                                                 --  print(pets.Name)   
  125.                                                 if p.Value == true then --not player.Character:FindFirstChild(pets.Name)               
  126.                                                     if player.PetsFolder:FindFirstChild("PetNameCheck").Value == pets.Name and player.Character:FindFirstChild(pets.Name) then
  127.                             --                          print("Pet was found in Character")
  128.                                                         v.PetPriceCheck.Text = "Equipped"
  129.                                                         for i,l in pairs(MainFrame:GetDescendants()) do
  130.                                                             if l:IsA("ImageButton") and l.Name == "PetsButton" then
  131.                                                                 if l:FindFirstChild("PetIndex").Value ~= player.PetsFolder:FindFirstChild("PetNameCheck").Value and player.PetsFolder:FindFirstChild("PetNameCheck").Value ~= ""  then -- and not v.Name
  132.                                                                     if l:FindFirstChild("PetPriceCheck").Text == "Equipped" then
  133.                                                                         l:FindFirstChild("PetPriceCheck").Text = "Owned"
  134.                             --                                          print("Name Change idk")
  135.                                                                     end
  136.                                                                 end
  137.                                                             end
  138.                                                         end
  139.                                                         break          
  140.                                                     end
  141.                                                     if player.PetsFolder:FindFirstChild("PetNameCheck").Value == "" and not player.Character:FindFirstChild(pets.Name) then
  142.                             --                          print("Pet was not found in Character")
  143.                                                         v.PetPriceCheck.Text = "Owned" 
  144.                                                         break
  145.                                                     end
  146.                                                 end        
  147.                                             end                
  148.                                         end                    
  149.                                        
  150.                                         button2:Disconnect()   
  151.                                         debounce = true    
  152.                                     end            
  153.                                 end)                   
  154.                                 --  debounce = true
  155.                                 --  return PetName         
  156.                             end    
  157.  
  158.                             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                                 
  159.                                 v.PetPriceCheck.Text = "Not Enough Coins"
  160.                                 wait(0.5)
  161.                                 v.PetPriceCheck.Text = v.Price.Value .. " Coins" -- resets the price to its default per pet                                                                                
  162.                                 --     print(p.Name .. " p.Name - second if statement")    
  163.                                 --     print(v:FindFirstChild("PetIndex").Value .. " v - second if statement")     
  164.                                 --     print(p.Value)      
  165.                                 debounce = true    
  166.                             end                
  167.                             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                      
  168.                                 --     print(p.Name .. " p.Name - Third if statement")     
  169.                                 --     print(v:FindFirstChild("PetIndex").Value .. " v - Third if statement")  
  170.                                 --     print(p.Value)          
  171.                                 --v.PetPriceCheck.Text = "Owned"       
  172.                                 PetsPurchaseEvent:FireServer(p)
  173.                         --      print("We own the pet firing remote event")
  174.                                 for i,pets in pairs(Pets)do
  175.                                     if pets:IsA("Model") then              
  176.                                         --  print(pets.Name)
  177.                                         if p.Value == true then        
  178.                                            
  179.                                             if v.PetPriceCheck.Text == "Equipped" and player.PetsFolder:FindFirstChild("PetNameCheck").Value ~= "" and player.PetsFolder:FindFirstChild("PetNameCheck").Value == v.PetIndex.Value then --pets.Name
  180.                                                 print("Pet was found in Character")
  181.                                                 v.PetPriceCheck.Text = "Owned" -- it was on Owned
  182.                                                 break          
  183.                                             end
  184.                                            
  185.                                         --[[    if v.PetPriceCheck.Text == "Equipped" and player.PetsFolder:FindFirstChild("PetNameCheck").Value ~= "" or player.PetsFolder:FindFirstChild("PetNameCheck").Value ~= v.PetIndex.Value then --pets.Name
  186.                                                 print("Pet was found in Character")
  187.                                                 v.PetPriceCheck.Text = "Equipped" -- it was on Owned
  188.                                                 -- we might need a loop in here
  189.                                                 break          
  190.                                             end--]]
  191.  
  192.                                             if v.PetPriceCheck.Text == "Owned" and player.PetsFolder:FindFirstChild("PetNameCheck").Value == "" or player.PetsFolder:FindFirstChild("PetNameCheck").Value == v.PetIndex.Value then             
  193.                                                 print("Pet was not found in Character")
  194.                                                 v.PetPriceCheck.Text = "Equipped"  
  195.                                                 for i,gamepass in pairs(MainFrame:GetDescendants()) do
  196.                                                     if gamepass:IsA("ImageButton") and gamepass.Name == "PetsGamepassButton" then
  197.                                                         if gamepass:FindFirstChild("Gamepass").Value then
  198.                                                             local id = gamepass.Gamepass.Value
  199.                                                             local ownsGamepass = game:GetService("MarketplaceService"):UserOwnsGamePassAsync(player.UserId,id)
  200.                                                             if ownsGamepass then
  201.                                                                 gamepass.PetPriceCheck.Text = "Owned"
  202.                                                             else
  203.                                                                 gamepass.PetPriceCheck.Text = gamepass.PetPriceCheck.Text  
  204.                                                             end
  205.                                                         end
  206.                                                     end
  207.                                                 end
  208.                                                 break
  209.                                             end    
  210.  
  211.                                             if v.PetPriceCheck.Text == "Owned" and player.PetsFolder:FindFirstChild("PetNameCheck").Value ~= "" or player.PetsFolder:FindFirstChild("PetNameCheck").Value ~= v.PetIndex.Value then             
  212.                                         --      print("Second Remove")         
  213.                     --                          print(v.Name)
  214.                                                 v.PetPriceCheck.Text = "Equipped"                      
  215.                                                 wait(.1)
  216.                                                 for i,z in pairs(MainFrame:GetDescendants()) do
  217.                                                     if z:IsA("ImageButton") and z.Name == "PetsButton" then
  218.                                                     --  print("Second Remove")
  219.                                                         if z:FindFirstChild("PetIndex").Value ~= player.PetsFolder:FindFirstChild("PetNameCheck").Value then
  220.                                                         --  print("Second Remove") -- runs to here
  221.                                                             if z.PetPriceCheck.Text == "Owned" or z.PetPriceCheck.Text == "Equipped" and p.Value == true and z:FindFirstChild("PetIndex").Value ~= p.Name then  -- it was Equipped -- and player.PetsFolder:FindFirstChild("PetNameCheck").Value ~= z:FindFirstChild("PetIndex").Value
  222.                                                         --      print("Second Remove")
  223.                                                                 z.PetPriceCheck.Text = "Owned"
  224.                                                                 for i,gamepass in pairs(MainFrame:GetDescendants()) do
  225.                                                                     if gamepass:IsA("ImageButton") and gamepass.Name == "PetsGamepassButton" then
  226.                                                             --          print("Second Remove")
  227.                                                                         if gamepass:FindFirstChild("Gamepass").Value then
  228.                                                                 --          print("Second Remove")
  229.                                                                             local id = gamepass.Gamepass.Value
  230.                                                                             local ownsGamepass = game:GetService("MarketplaceService"):UserOwnsGamePassAsync(player.UserId,id)
  231.                                                                             if ownsGamepass then
  232.                                                                                 gamepass.PetPriceCheck.Text = "Owned"
  233.                                                                             else
  234.                                                                                 gamepass.PetPriceCheck.Text = gamepass.PetPriceCheck.Text  
  235.                                                                           end
  236.                                                                        end
  237.                                                                     end
  238.                                                                 end
  239.                                                             end
  240.                                                         end
  241.                                                     end
  242.                                                 end
  243.                                                 wait() 
  244.                                                 --[[for i,l in pairs(MainFrame:GetDescendants()) do
  245.                                                     if l:IsA("ImageButton") and l.Name == "PetsButton" then
  246.                                                         if l:FindFirstChild("PetIndex").Value ~= player.PetsFolder:FindFirstChild("PetNameCheck").Value and player.PetsFolder:FindFirstChild("PetNameCheck").Value ~= "" then -- and not v.Name
  247.                                                             if l:FindFirstChild("PetPriceCheck").Text == "Equipped" then
  248.                                                                 l:FindFirstChild("PetPriceCheck").Text = "Equipped"--Owned
  249.                                                                 print("Name Change idk")
  250.                                                                 --break
  251.                                                             end
  252.                                                         end
  253.                                                     end
  254.                                                 end--]]
  255.  
  256.                                                break
  257.                                             end
  258.  
  259.                                 --[[        if v.PetPriceCheck.Text == "Equipped" and player.PetsFolder:FindFirstChild("PetNameCheck").Value == "" then            
  260.                                             print("Second Equip")  
  261.                                             v.PetPriceCheck.Text = "Equipped"  
  262.                                             for i,l in pairs(MainFrame:GetDescendants()) do
  263.                                                 if l:IsA("ImageButton") and l.Name == "PetsButton" then
  264.                                                     if l:FindFirstChild("PetIndex").Value ~= player.PetsFolder:FindFirstChild("PetNameCheck").Value then
  265.                                                         if l:FindFirstChild("PetPriceCheck").Text == "Equipped" then
  266.                                                             l:FindFirstChild("PetPriceCheck").Text = "Owned"
  267.                                                             print("Name Change idk")
  268.                                                         end
  269.                                                     end
  270.                                                 end
  271.                                             end
  272.                                            
  273.                                             break
  274.                                         end
  275.                                     end
  276.                                 end                
  277.                             end --]]
  278.                                             --  v.PetPriceCheck.Text = v.Price.Value .. " Coins"
  279.                                         end
  280.                                     end                                        
  281.                                 end    
  282.                                 debounce = true        
  283.                             end        
  284.                             --  debounce = true    
  285.  
  286.                             --print("Making sure you work")                            
  287.                     wait() 
  288.                     --break
  289.                         end    
  290.                     end        
  291.                 end
  292.                 RunTest()
  293.                 button1:Disconnect()
  294.             end)
  295.         end
  296.     end
  297.  
  298.     if v:IsA("ImageButton") and v.Name == "PetsGamepassButton" then
  299.         --print("not my nigga") -- script will run when player is loaded basically the for loop:)
  300.         button3 = v.MouseButton1Down:Connect(function()
  301.             button3:Disconnect()
  302.             if debounce and player then        
  303.                 debounce = false
  304.         --      print("not my nigga")  
  305.                 local id = v:FindFirstChild("Gamepass").Value
  306.                 local Name = v:FindFirstChild("PetIndex").Value
  307.                 local TextPrice = v:FindFirstChild("PetPriceCheck").Text
  308.                 local ownsGamepass = game:GetService("MarketplaceService"):UserOwnsGamePassAsync(player.UserId,id)
  309.             --  local success, errormessage = pcall(ownsGamepass);
  310.             --  print(id)  
  311.             --  print(Name)
  312.                 if ownsGamepass then
  313.         --          print("he owns it")
  314.                     PetsGamepassEvent:FireServer(id,Name)
  315.                 else
  316.         --          print("he doesnt own the gamepass!!")
  317.                     PetsGamepassEvent:FireServer(id,Name)
  318.                 end
  319.                 debounce = true
  320.               end
  321.            end)
  322.         end
  323.    
  324.     if v:IsA("ImageButton") and v.Name == "PetsHiddenButton" then -- hidden experiment stuff
  325.         --print("not my nigga") -- script will run when player is loaded basically the for loop:)
  326.         v.MouseButton1Down:Connect(function()
  327.             if debounce and player then        
  328.                 -- if stat bla bla = true then do this bam
  329.         --      print("not my hidden nigga")                       
  330.             end
  331.         end)
  332.     end
  333. end
  334.  
  335. CancelButton.MouseButton1Down:Connect(function()
  336.     if not debounce and player then
  337.         --debounce = false
  338.         BuyFrame:TweenPosition(
  339.             UDim2.new(0.499, 0,-1, 0),-- End Position      
  340.             "Out", -- Easing Direction
  341.             "Linear", -- Easing Style
  342.             .5 -- Time in Seconds
  343.         )      
  344.         wait(.5)
  345.         button2:Disconnect()
  346.         BuyFrame.Visible = false   
  347.         debounce = true
  348.     end
  349. end)
  350.  
  351. local PetGamepassButton = script.Parent.Frame34.ImageButton.PetsGamepassButton
  352.  
  353. PetGamepassButton.MouseButton1Down:Connect(function()
  354. --  print("Hello") 
  355.     if debounce and player then        
  356.         debounce = false
  357.     --  print("not my nigga")  
  358.         local id = PetGamepassButton:FindFirstChild("Gamepass").Value
  359.         local Name = PetGamepassButton:FindFirstChild("PetIndex").Value
  360.         local TextPrice = PetGamepassButton:FindFirstChild("PetPriceCheck").Text
  361.         local ownsGamepass = game:GetService("MarketplaceService"):UserOwnsGamePassAsync(player.UserId,id)
  362.         if ownsGamepass then
  363.     --      print("he owns it")
  364.             PetsGamepassEvent:FireServer(id,Name)
  365.         else
  366.     --      print("he doesnt own the gamepass!!")
  367.             PetsGamepassEvent:FireServer(id,Name)
  368.         end
  369.         debounce = true
  370.     end
  371. end)
  372.  
  373.  
  374. local function onNotifyPlayer(Name,id)
  375. --  print("Incoming server event...")
  376. --  print(Name,id)
  377.     local ownsGamepass = game:GetService("MarketplaceService"):UserOwnsGamePassAsync(player.UserId,id)
  378.     for i,v in pairs(MainFrame:GetDescendants()) do    
  379.         if v:IsA("ImageButton") and v.Name == "PetsGamepassButton" and Name == v.PetIndex.Value then   
  380.             for i,z in pairs(MainFrame:GetDescendants()) do
  381.                 if z:IsA("ImageButton") and z.Name == "PetsButton" then
  382.                     for i,pets in pairs(Pets) do                               
  383.                         if pets:IsA("Model") and pets.Name == Name then            
  384.                         --  print("Hello")
  385.                         --  print(pets.Name)
  386.                             if ownsGamepass then
  387.                             --  print("he owns it") -- this works!!
  388.                                 if z.PetPriceCheck.Text == "Equipped" and player.PetsFolder:FindFirstChild("PetNameCheck").Value ~= "" and player.PetsFolder:FindFirstChild("PetNameCheck").Value == Name then
  389.                             --      print("Pet was found in Character")
  390.                                     z.PetPriceCheck.Text = "Owned" -- it was on Owned
  391.                                     if player.PetsFolder:FindFirstChild("PetNameCheck").Value == Name then
  392.                                     --  print(Name)
  393.                                     --  print(id)
  394.                                     --  print(player.PetsFolder:FindFirstChild("PetNameCheck").Value)
  395.                                     --  print(id == v.Gamepass.Value)
  396.                                 --      print(v.Gamepass.Value)
  397.                                         if v.Gamepass.Value == id then                                     
  398.                         --              print(Name)            
  399.                                         v.PetPriceCheck.Text = "Equipped"  
  400.                                         end
  401.                                     end    
  402.                                    return
  403.                                 end
  404.                                
  405.                             --[[    if z.PetPriceCheck.Text == "Owned" and player.PetsFolder:FindFirstChild("PetNameCheck").Value ~= "" and player.PetsFolder:FindFirstChild("PetNameCheck").Value == Name then
  406.                                     print("Pet was found in Character")
  407.                                     if player.PetsFolder:FindFirstChild("PetNameCheck").Value == Name then
  408.                                             print(Name)
  409.                                         if v.Gamepass.Value == id then                                     
  410.                                             print(Name)            
  411.                                             v.PetPriceCheck.Text = "Owned" 
  412.                                         end
  413.                                     end    
  414.                                     return
  415.                                 end --]]
  416.                                
  417.                                
  418.                                
  419.                                 if z.PetPriceCheck.Text == "Owned" and player.PetsFolder:FindFirstChild("PetNameCheck").Value == "" then
  420.                                 --  print(Name)    
  421.                                     if v.PetPriceCheck.Text == "Equipped" and v.Gamepass.Value == id then
  422.                         --              print(Name)    
  423.                                 --      if v.Gamepass.Value == id then                                     
  424.                                     --      print(Name)            
  425.                                             v.PetPriceCheck.Text = "Owned"
  426.                                             break
  427.                                 --      end
  428.                                     end
  429.                                 end
  430.                                
  431.                                 if z.PetPriceCheck.Text == "Owned" and player.PetsFolder:FindFirstChild("PetNameCheck").Value == Name then
  432.                                     if v.PetPriceCheck.Text == "Owned" and v.Gamepass.Value == id then                         
  433.                             --              print(Name)             -- tozi red
  434.                                             v.PetPriceCheck.Text = "Equipped"
  435.                                             wait()
  436.                                             for i,namechange in pairs(MainFrame:GetDescendants()) do
  437.                                             if namechange:IsA("ImageButton") and namechange.Name == "PetsGamepassButton" and Name ~= namechange:FindFirstChild("PetIndex").Value and v.Gamepass.Value == id then
  438.                                                 if namechange:FindFirstChild("PetPriceCheck").Text == "Equipped" and v.Gamepass.Value == id then
  439.                                                  print("idk")
  440.                                                  namechange.PetPriceCheck.Text = "Owned"                   
  441.                                               end
  442.                                            end 
  443.                                         end
  444.                                     end
  445.                                 end
  446.                                            
  447.                                
  448.                                
  449.                             --[[    if z.PetPriceCheck.Text == "Owned" and player.PetsFolder:FindFirstChild("PetNameCheck").Value ~= "" then
  450.                                     print("idk1")  
  451.                                     if v.PetPriceCheck.Text == "Equipped" then
  452.                                         print("idk2")  
  453.                                         if v.Gamepass.Value == id then                                     
  454.                                             print(Name)            
  455.                                             v.PetPriceCheck.Text = "Owned"
  456.                                             return
  457.                                         end
  458.                                     end
  459.                                 end--]]
  460.                         --[[   
  461.                                 if z.PetPriceCheck.Text == "Owned" and player.PetsFolder:FindFirstChild("PetNameCheck").Value == "" then
  462.                                     print("idk1")  
  463.                                     if v.PetPriceCheck.Text == "Owned" then
  464.                                         print("idk2")  
  465.                                         if v.Gamepass.Value == id then                                     
  466.                                             print(Name)            
  467.                                             v.PetPriceCheck.Text = "Equipped"
  468.                                             return
  469.                                         end
  470.                                     end
  471.                                 end--]]
  472.                                
  473.                             --[[
  474.                                 if v.PetPriceCheck.Text == "Owned" and player.PetsFolder:FindFirstChild("PetNameCheck").Value == ""  then --and player.PetsFolder:FindFirstChild("PetNameCheck").Value == Name
  475.                                    
  476.                                     v.PetPriceCheck.Text = "Equipped"
  477.                                     print(Name)
  478.                                     break
  479.                                 end--]]
  480.                             --[[   
  481.                                 if v.PetPriceCheck.Text == "Equipped" and player.PetsFolder:FindFirstChild("PetNameCheck").Value ~= "" and player.PetsFolder:FindFirstChild("PetNameCheck").Value == Name then
  482.                                    
  483.                                     v.PetPriceCheck.Text = "Owned"
  484.                                     print(Name)
  485.                                     break
  486.                                 end--]]                
  487.                             else
  488.                             --  print("he doesnt own the gamepass!!")
  489.                                 break
  490.                             end                        
  491.                         end
  492.                     end
  493.                 end
  494.             end
  495.         end
  496.     end
  497. end
  498.  
  499. PetsGamepassEvent.OnClientEvent:Connect(onNotifyPlayer)
  500. -- ServerSide Script
  501. local DataStoreService = game:GetService("DataStoreService")
  502. local Petsdata = DataStoreService:GetDataStore("PetShop2")
  503. local ReplicatedStorage = game:GetService("ReplicatedStorage")
  504. local MarketplaceService = game:GetService("MarketplaceService")
  505. local PetsFolder = ReplicatedStorage.Pets
  506. local PetsPurchaseEvent = PetsFolder.PetEvents.PetsPurchase
  507. local PetsGamepassEvent = PetsFolder.PetEvents.PetGamepass
  508. local Pets = PetsFolder.ActualPets:GetChildren()
  509. local Market
  510. local debounce = true
  511.  
  512. game.Players.PlayerAdded:Connect(function(player)
  513.     --Pets stuff
  514.     local PetsFolder = Instance.new("Folder",player); PetsFolder.Name = "PetsFolder"
  515.     local Pets = Instance.new("Folder",PetsFolder); Pets.Name = "Pets"
  516.     local PetsValues = Instance.new("Folder",PetsFolder); PetsValues.Name = "Values"
  517.     local PetNameCheck = Instance.new("StringValue",PetsFolder); PetNameCheck.Name = "PetNameCheck"
  518.     --Pets Values
  519.     local Turtle = Instance.new("BoolValue",PetsValues); Turtle.Name = "Turtle"
  520.     local Bunny = Instance.new("BoolValue",PetsValues); Bunny.Name = "Bunny"
  521.     local Parrot = Instance.new("BoolValue",PetsValues); Parrot.Name = "Parrot"
  522.     local PiggyBank = Instance.new("BoolValue",PetsValues); PiggyBank.Name = "Piggy Bank"
  523.     local MrCrab = Instance.new("BoolValue",PetsValues); MrCrab.Name = "Mr.Crab"
  524.     local PufferFish = Instance.new("BoolValue",PetsValues); PufferFish.Name = "Puffer Fish"
  525.     local Hedgehog = Instance.new("BoolValue",PetsValues); Hedgehog.Name = "Hedgehog"
  526.     local CrocodilePal = Instance.new("BoolValue",PetsValues); CrocodilePal.Name = "CrocodilePal"
  527.     local KingFrog = Instance.new("BoolValue",PetsValues); KingFrog.Name = "King Frog"
  528.     local Kitty = Instance.new("BoolValue",PetsValues); Kitty.Name = "Kitty"
  529.     local EpicDuck = Instance.new("BoolValue",PetsValues); EpicDuck.Name = "Epic Duck"
  530.     local Octopus = Instance.new("BoolValue",PetsValues); Octopus.Name = "Octopus"
  531.     local PetRock = Instance.new("BoolValue",PetsValues); PetRock.Name = "Pet Rock"
  532.     local SeaMonster = Instance.new("BoolValue",PetsValues); SeaMonster.Name = "Sea Monster"
  533.     local Pikachu = Instance.new("BoolValue",PetsValues); Pikachu.Name = "Pikachu"
  534.     local OOFSpider = Instance.new("BoolValue",PetsValues); OOFSpider.Name = "OOF Spider"
  535.     local PetGojira = Instance.new("BoolValue",PetsValues); PetGojira.Name = "Pet Gojira"
  536.     local Scorpion = Instance.new("BoolValue",PetsValues); Scorpion.Name = "Scorpion"
  537.     local HungryShark = Instance.new("BoolValue",PetsValues); HungryShark.Name = "Hungry Shark"
  538.     local AnnoyingOrange = Instance.new("BoolValue",PetsValues); AnnoyingOrange.Name = "Annoying Orange"
  539.     local EvilUnicorn = Instance.new("BoolValue",PetsValues); EvilUnicorn.Name = "Evil Unicorn"
  540.     local ArcticReindeer = Instance.new("BoolValue",PetsValues); ArcticReindeer.Name = "Arctic Reindeer"
  541.     local Bird = Instance.new("BoolValue",PetsValues); Bird.Name = "Bird"
  542.     local GrayWolf = Instance.new("BoolValue",PetsValues); GrayWolf.Name = "Gray Wolf"
  543.     local Dog = Instance.new("BoolValue",PetsValues); Dog.Name = "Dog"
  544.     local Otter = Instance.new("BoolValue",PetsValues); Otter.Name = "Otter"
  545.     local AlienBee = Instance.new("BoolValue",PetsValues); AlienBee.Name = "Alien Bee"
  546.     local TRex = Instance.new("BoolValue",PetsValues); TRex.Name = "T-Rex"
  547.     local Phoenix = Instance.new("BoolValue",PetsValues); Phoenix.Name = "Phoenix"
  548.     local HellDragon = Instance.new("BoolValue",PetsValues); HellDragon.Name = "Hell Dragon"
  549.     --Hidden Pet Value
  550.     local HiddenPetValue = Instance.new("BoolValue",PetsValues); HiddenPetValue.Name = "Eye of Cthulhu"
  551.    
  552.     local Player = "Player_"..player.UserId
  553.  
  554.     --Load Data
  555.     local data
  556.     local success, errormessage = pcall(function()
  557.         data = Petsdata:GetAsync(Player) --.UserId
  558.     end)
  559.  
  560.     if success then
  561.         if data then
  562.             PetNameCheck.Value = data.PetNameCheck;
  563.             Turtle.Value = data.Turtle;
  564.             Bunny.Value = data.Bunny;
  565.             Parrot.Value = data.Parrot;
  566.             PiggyBank.Value = data.PiggyBank;
  567.             MrCrab.Value = data.MrCrab;
  568.             PufferFish.Value = data.PufferFish;
  569.             Hedgehog.Value = data.Hedgehog;
  570.             CrocodilePal.Value = data.CrocodilePal;
  571.             KingFrog.Value = data.KingFrog;
  572.             Kitty.Value = data.Kitty;
  573.             EpicDuck.Value = data.EpicDuck;
  574.             Octopus.Value = data.Octopus;
  575.             PetRock.Value = data.PetRock;
  576.             SeaMonster.Value = data.SeaMonster;
  577.             Pikachu.Value = data.Pikachu;
  578.             OOFSpider.Value = data.OOFSpider;
  579.             PetGojira.Value = data.PetGojira;
  580.             Scorpion.Value = data.Scorpion;
  581.             HungryShark.Value = data.HungryShark;
  582.             AnnoyingOrange.Value = data.AnnoyingOrange;
  583.             EvilUnicorn.Value = data.EvilUnicorn;
  584.             ArcticReindeer.Value = data.ArcticReindeer;
  585.             Bird.Value = data.Bird;
  586.             GrayWolf.Value = data.GrayWolf;
  587.             Dog.Value = data.Dog;
  588.             Otter.Value = data.Otter;
  589.             AlienBee.Value = data.AlienBee;
  590.             TRex.Value = data.TRex;
  591.             Phoenix.Value = data.Phoenix;
  592.             HellDragon.Value = data.HellDragon;
  593.             HiddenPetValue.Value = data.HiddenPetValue;
  594.         end        
  595.     end    
  596.    
  597.     if player.Character then
  598.         local Pets = game:GetService("ReplicatedStorage").Pets.ActualPets:GetChildren()
  599.         for i,pets in pairs(Pets) do       
  600.             if pets:IsA("Model") then
  601.                 if player.PetsFolder:FindFirstChild("PetNameCheck").Value == pets.Name then
  602.                     local pet = pets:Clone()
  603.                     pet.Parent = player.Character
  604.                     break
  605.                 end
  606.             end
  607.         end
  608.     end
  609.    
  610.     player.CharacterAdded:Connect(function(Character)
  611.     --  print("Spawn")
  612.         if Character then
  613.         local Pets = game:GetService("ReplicatedStorage").Pets.ActualPets:GetChildren()
  614.         for i,pets in pairs(Pets) do       
  615.             if pets:IsA("Model") then
  616.                 if player.PetsFolder:FindFirstChild("PetNameCheck").Value == pets.Name then
  617.                     local pet = pets:Clone()
  618.                     pet.Parent = player.Character
  619.                       break
  620.                    end 
  621.                 end
  622.             end
  623.         end
  624.     end)
  625. end)
  626.  
  627. game.Players.PlayerRemoving:Connect(function(player)
  628.    
  629.     local Player = "Player_"..player.UserId
  630.    
  631.     local data = {
  632.         Turtle = player.PetsFolder.Values.Turtle.Value;
  633.         Bunny = player.PetsFolder.Values.Bunny.Value;
  634.         Parrot = player.PetsFolder.Values.Parrot.Value;
  635.         PiggyBank = player.PetsFolder.Values["Piggy Bank"].Value;
  636.         MrCrab = player.PetsFolder.Values["Mr.Crab"].Value;
  637.         PufferFish = player.PetsFolder.Values["Puffer Fish"].Value;
  638.         Hedgehog = player.PetsFolder.Values.Hedgehog.Value;
  639.         CrocodilePal = player.PetsFolder.Values.CrocodilePal.Value;
  640.         KingFrog = player.PetsFolder.Values["King Frog"].Value;
  641.         Kitty = player.PetsFolder.Values.Kitty.Value;
  642.         EpicDuck = player.PetsFolder.Values["Epic Duck"].Value;
  643.         Octopus = player.PetsFolder.Values.Octopus.Value;
  644.         PetRock = player.PetsFolder.Values["Pet Rock"].Value;
  645.         SeaMonster = player.PetsFolder.Values["Sea Monster"].Value;
  646.         Pikachu = player.PetsFolder.Values.Pikachu.Value;
  647.         OOFSpider = player.PetsFolder.Values["OOF Spider"].Value;
  648.         PetGojira = player.PetsFolder.Values["Pet Gojira"].Value;
  649.         Scorpion = player.PetsFolder.Values.Scorpion.Value;
  650.         HungryShark = player.PetsFolder.Values["Hungry Shark"].Value;
  651.         AnnoyingOrange = player.PetsFolder.Values["Annoying Orange"].Value;
  652.         EvilUnicorn = player.PetsFolder.Values["Evil Unicorn"].Value;
  653.         ArcticReindeer = player.PetsFolder.Values["Arctic Reindeer"].Value;
  654.         Bird = player.PetsFolder.Values.Bird.Value;
  655.         GrayWolf = player.PetsFolder.Values["Gray Wolf"].Value;
  656.         Dog = player.PetsFolder.Values.Dog.Value;
  657.         Otter = player.PetsFolder.Values.Otter.Value;
  658.         AlienBee = player.PetsFolder.Values["Alien Bee"].Value;
  659.         TRex = player.PetsFolder.Values["T-Rex"].Value;
  660.         Phoenix = player.PetsFolder.Values.Phoenix.Value;
  661.         HellDragon = player.PetsFolder.Values["Hell Dragon"].Value;
  662.         HiddenPetValue = player.PetsFolder.Values["Eye of Cthulhu"].Value;
  663.         PetNameCheck = player.PetsFolder.PetNameCheck.Value;
  664.     };
  665.  
  666.     local success, errormessage = pcall(function()
  667.         Petsdata:SetAsync(Player, data)
  668.     end)
  669.  
  670.     if success then
  671.         print("Pets successfully saved:)")
  672.     else
  673.         print("There was an error!")
  674.         warn(errormessage)
  675.     end
  676.    
  677. end)
  678.  
  679. PetsPurchaseEvent.OnServerEvent:Connect(function(player,p,PetPrice)
  680.     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("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")  
  681. --  print("Received Server message")
  682. --  print(p)
  683. --  print(p.Name)
  684.     local Values = player.PetsFolder.Values
  685.     for i,v in pairs(Values:GetDescendants()) do
  686.         if v:IsA("BoolValue") then
  687.             --print(v.Name)
  688.             --print(v.Name == p.Name)
  689.             if v.Name == p.Name then
  690.             --  print("To the Next Step")
  691.                 --  print(v.Name == p)
  692.             --  print(v.Name)
  693.             --  print(v.Value)
  694.                 if v.Value == true then
  695.                 --  print(v.Name.." Owned")
  696.                     for i,pets in pairs(Pets) do
  697.                     --  print(pets.Name)
  698.                         if pets:IsA("Model") and p.Name == pets.Name then
  699.                     --      print(pets.Name)
  700.                     ----        print(v.Name.." v.Name")
  701.                     --      print(p.Name.." p.Name")
  702.                     --      print(pets.Name.." pets.Name")
  703.                             --local previouspet =   pets
  704.                             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("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")
  705.                             if previouspet and player.PetsFolder:FindFirstChild("PetNameCheck").Value ~= p.Name  then --or player.PetsTestFolder:FindFirstChild("PetNameCheck").Value ~= ""
  706.                     --          print("Pet owned and its not the same so we will destroy it")
  707.                     --          print("Destroy")
  708.                                 --local pet =   player.Character:FindFirstChild(pets.Name):Destroy()
  709.                                 --player.Character:FindFirstChild(pets.Name):Destroy()
  710.                                 previouspet:Destroy()
  711.                                 player.PetsFolder:FindFirstChild("PetNameCheck").Value = ""
  712.                                 local pet = pets:Clone()
  713.                                 pet.Parent = player.Character
  714.                                 player.PetsFolder:FindFirstChild("PetNameCheck").Value = pets.Name
  715.                                 break
  716.                             end
  717.                             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
  718.                     --          print("Pet owned and its in inventory so we will destroy it")
  719.                     --          print("Destroy")
  720.                                 --local pet =   player.Character:FindFirstChild(pets.Name):Destroy()
  721.                                 --player.Character:FindFirstChild(pets.Name):Destroy()
  722.                                 previouspet:Destroy()
  723.                                 player.PetsFolder:FindFirstChild("PetNameCheck").Value = ""
  724.                                 break
  725.                             end
  726.                             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
  727.                 --              print("Pet owned and its not in inventory so we will clone it")
  728.                 --              print("Clone")
  729.                                 local pet = pets:Clone()
  730.                                 pet.Parent = player.Character
  731.                                 player.PetsFolder:FindFirstChild("PetNameCheck").Value = pets.Name
  732.                                 break  
  733.                             end
  734.                     --[[        if previouspet and v.Name ~= p.Name and player.PetsFolder:FindFirstChild("PetNameCheck").Value ~= p.Name then -- something is fishy about this line of code
  735.                                 previouspet:Destroy()
  736.                                 player.PetsFolder:FindFirstChild("PetNameCheck").Value = ""
  737.                                 local pet = pets:Clone()
  738.                                 pet.Parent = player.Character
  739.                                 player.PetsFolder:FindFirstChild("PetNameCheck").Value = pets.Name
  740.                                 break  
  741.                             end--]]        
  742.                         end
  743.                     end
  744.                 else
  745.                 --  print(v.Name.." Not Owned")
  746.                 --  print(PetPrice)
  747.                     if player.leaderstats.Coins.Value >= PetPrice then 
  748.                     player.leaderstats.Coins.Value = player.leaderstats.Coins.Value - PetPrice
  749.                     v.Value = true 
  750.                         for i,pets in pairs(Pets) do
  751.                             if p.Name == pets.Name then
  752.                                 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("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")
  753.                                 if previouspet and player.PetsFolder:FindFirstChild("PetNameCheck").Value ~= "" then
  754.                             --  print("Checking Before Cloning")   
  755.                                 previouspet:Destroy()
  756.                                 player.PetsFolder:FindFirstChild("PetNameCheck").Value = ""
  757.                                 local pet = pets:Clone()
  758.                                 pet.Parent = player.Character
  759.                                 player.PetsFolder:FindFirstChild("PetNameCheck").Value = pets.Name
  760.                                 else   
  761.                         --      print("Cloning")
  762.                                 --print(pets)
  763.                                 local pet = pets:Clone()
  764.                                 pet.Parent = player.Character
  765.                                 player.PetsFolder:FindFirstChild("PetNameCheck").Value = pets.Name
  766.                                 end
  767.                             end
  768.                         end
  769.                     else
  770.                         print("Player Doesnt Have the Coin,Hes Poor")
  771.                     end
  772.                 end    
  773.             end
  774.         end
  775.     end
  776. end)
  777.  
  778. PetsGamepassEvent.OnServerEvent:Connect(function(player,id,Name)   
  779.     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("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")
  780.     local ownsGamepass = game:GetService("MarketplaceService"):UserOwnsGamePassAsync(player.UserId,id)
  781.     local success, errormessage = pcall(ownsGamepass);
  782.   --print(player)
  783. --  print(id)
  784. --  print(Name)
  785.     if player and not ownsGamepass then        
  786.         game:GetService("MarketplaceService"):PromptGamePassPurchase(player,id)
  787.     --  print(Name)
  788.         local function gamepassPurchaseFinished(player,id,wasPurchased)    
  789.             Market:Disconnect()
  790.             if wasPurchased == true then
  791.                 print("Purchased") 
  792.             --  print(id)  
  793.             --  print(Name)
  794.                 for i,pets in pairs(Pets) do
  795.                   --print(pets.Name)
  796.                 --  print(Name)
  797.                     if pets:IsA("Model") and pets.Name == Name then
  798.                         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("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")
  799.                         if previouspet and player.PetsFolder:FindFirstChild("PetNameCheck").Value ~= "" then
  800.                             previouspet:Destroy()
  801.                             player.PetsFolder:FindFirstChild("PetNameCheck").Value = ""
  802.                             local pet = pets:Clone()
  803.                             pet.Parent = player.Character
  804.                             player.PetsFolder:FindFirstChild("PetNameCheck").Value = pets.Name
  805.                             PetsGamepassEvent:FireClient(player,Name,id)
  806.                         else
  807.                             local pet = pets:Clone()
  808.                             pet.Parent = player.Character
  809.                             player.PetsFolder:FindFirstChild("PetNameCheck").Value = pets.Name
  810.                             PetsGamepassEvent:FireClient(player,Name,id)
  811.                       end
  812.                    end     
  813.                 end
  814.             else
  815.                 print("Canceled")
  816.                 return
  817.             end
  818.         end    
  819.         Market = MarketplaceService.PromptGamePassPurchaseFinished:Connect(gamepassPurchaseFinished)
  820.     end
  821.    
  822.     if player and ownsGamepass then        
  823.         for i,pets in pairs(Pets) do
  824.           --print(pets.Name)
  825.         --  print(Name)
  826.             if pets:IsA("Model") and pets.Name == Name then
  827.         --      print("We own it") -- If we Own the gamepass
  828.                 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("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")
  829.                 if previouspet and player.PetsFolder:FindFirstChild("PetNameCheck").Value ~= Name  then
  830.                     print("idk")
  831.                     previouspet:Destroy()
  832.                     player.PetsFolder:FindFirstChild("PetNameCheck").Value = ""
  833.                     local pet = pets:Clone()
  834.                     pet.Parent = player.Character
  835.                     player.PetsFolder:FindFirstChild("PetNameCheck").Value = pets.Name
  836.                     PetsGamepassEvent:FireClient(player,Name,id)
  837.                     break
  838.                 end
  839.                 if previouspet and player.PetsFolder:FindFirstChild("PetNameCheck").Value == Name and previouspet.Name == Name then
  840.                     print("idk")
  841.                     previouspet:Destroy()
  842.                     player.PetsFolder:FindFirstChild("PetNameCheck").Value = ""
  843.                     PetsGamepassEvent:FireClient(player,Name,id)
  844.                     break
  845.                  end
  846.                 if not previouspet and player.PetsFolder:FindFirstChild("PetNameCheck").Value == "" and pets.Name == Name then
  847.                     print("idk")
  848.                     local pet = pets:Clone()
  849.                     pet.Parent = player.Character
  850.                     player.PetsFolder:FindFirstChild("PetNameCheck").Value = pets.Name
  851.                     PetsGamepassEvent:FireClient(player,Name,id)
  852.                 break  
  853.              end
  854.           end  
  855.        end     
  856.     end
  857. end)
Add Comment
Please, Sign In to add comment