Advertisement
qsenko1

PetShop Client SIde

Jun 29th, 2021
988
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.12 KB | None | 0 0
  1. for i,v in pairs(MainFrame:GetDescendants())do
  2.     if v:IsA("ImageButton") and v.Name == "PetsButton" then    
  3.         for i,p in ipairs(PetValues)do    
  4.         v.MouseButton1Down:Connect(function()            
  5.         local function RunTest()                                            
  6.         if p:IsA("BoolValue") and v:FindFirstChild("PetIndex").Value and v:FindFirstChild("PetIndex").Value == p.Name then    
  7.             if debounce and player then    
  8.                debounce = false                          
  9.                 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
  10.                     local Frame = player:FindFirstChild("PlayerGui"):FindFirstChild("PetsPurchaseGui"):FindFirstChild("BuyPet")        
  11.                     local FrameInfo = Frame:FindFirstChild("Desc")
  12.                     local PetName =    v:FindFirstChild("PetIndex").Value
  13.                     local PetPrice = v:FindFirstChild("Price").Value          
  14.                     print(v:FindFirstChild("PetIndex").Value .. " v - first if statement")            
  15.                     print(p.Name .. " p.Name - 1st if statement")        
  16.                     print(p.Value)            
  17.                     FrameInfo.Text = "Are you Sure you want to buy this " .. PetName .. " for " .. PetPrice .. " Coins"            
  18.                     Frame:TweenPosition(
  19.                         UDim2.new(0.499, 0,0.494, 0),
  20.                         "Out",
  21.                         "Linear",
  22.                         .5
  23.                     )    
  24.                     Frame.Visible = true
  25.                     wait(.5)            
  26.                     debounce = true    
  27.                     BuyButton.MouseButton1Down:Connect(function()    
  28.                         print(v:FindFirstChild("PetIndex").Value .. " v - first if statement")            
  29.                         print(p.Name .. " p.Name - 1st if statement")        
  30.                         print(p.Value)                
  31.                     end)        
  32.                 end                
  33.                 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                            
  34.                        v.PetPriceCheck.Text = "Not Enough Coins"
  35.                        wait(0.5)
  36.                        v.PetPriceCheck.Text = v.Price.Value .. " Coins"        
  37.                        debounce = true        
  38.                     end                    
  39.                 if p.Value == true then
  40.                        PetsPurchaseEvent:FireServer(player,p)    
  41.                        print("We own the pet firing remote event")    
  42.                        debounce = true            
  43.                     end                
  44.                     debounce = true            
  45.                 end                                            
  46.             end        
  47.                 wait()    
  48.                 end                
  49.             RunTest()    
  50.            end)
  51.         end    
  52.     end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement