qsenko1

My PetShop Gui Structure

Jun 25th, 2021
180
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 4.17 KB | None | 0 0
  1. local RS = game:GetService("ReplicatedStorage") -- the actual Service in what we have all the Pets,Events stored and etc.
  2. local PetsFolder = RS.Pets
  3. local PetsFrameEvent = PetsFolder.PetEvents.PetFrame -- the event that we need for the purchase frame to pop up
  4. local HiddenPetEvent = PetsFolder.PetEvents.HiddenPetEvent
  5. local MainFrame = script.Parent -- the frame that we will use to loop and get all objects,("instances") from!!!
  6. 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!!
  7. local player = game:GetService("Players").LocalPlayer -- thats a easy way of getting the local Player
  8. local PetValues = player.PetsFolder.Values:GetDescendants()      --:GetChildren()
  9.  
  10. for i,v in pairs(MainFrame:GetDescendants())do
  11.     if v:IsA("ImageButton") and v.Name == "PetsButton" then    
  12.         for i,p in ipairs(PetValues)do         
  13.         v.MouseButton1Down:Connect(function()          
  14.         local function RunTest()                                           
  15.         if p:IsA("BoolValue") and v:FindFirstChild("PetIndex").Value and v:FindFirstChild("PetIndex").Value == p.Name then
  16.             if debounce and player then    
  17.                debounce = false
  18.                --local PetIsName = v:FindFirstChild("PetIndex").Value                                                                                                                                  
  19.                 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
  20.                     --and v:FindFirstChild("PetIndex").Value == p.Name -- and p[PetIsName] and p.Name == PetIsName 
  21.                     local Frame = player:FindFirstChild("PlayerGui"):FindFirstChild("PetsPurchaseGui"):FindFirstChild("BuyPet")    
  22.                     local FrameInfo = Frame:FindFirstChild("Desc")
  23.                     local PetName = v:FindFirstChild("PetIndex").Value
  24.                     local PetPrice = v:FindFirstChild("Price").Value           
  25.                 --  print(v:FindFirstChild("PetIndex").Value .. " v - first if statement")         
  26.                 --  print(p.Name .. " p.Name - 1st if statement")      
  27.                 --  print(p.Value)         
  28.                     FrameInfo.Text = "Are you Sure you want to buy this " .. PetName .. " for " .. PetPrice .. " Coins"        
  29.                     Frame:TweenPosition(
  30.                         UDim2.new(0.499, 0,0.494, 0),-- End Position       
  31.                         "Out", -- Easing Direction
  32.                         "Linear", -- Easing Style
  33.                         .5 -- Time in Seconds
  34.                     )  
  35.                     Frame.Visible = true
  36.                     debounce = true            
  37.                 end            
  38.                 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                                 
  39.                        v.PetPriceCheck.Text = "Not Enough Coins"
  40.                        wait(0.5)
  41.                        v.PetPriceCheck.Text = v.Price.Value .. " Coins" -- resets the price to its default per pet                   
  42.                 --     print(p.Name .. " p.Name - second if statement")    
  43.                 --     print(v:FindFirstChild("PetIndex").Value .. " v - second if statement")     
  44.                 --     print(p.Value)      
  45.                        debounce = true     
  46.                     end                
  47.                 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                      
  48.                 --     print(p.Name .. " p.Name - Third if statement")     
  49.                 --     print(v:FindFirstChild("PetIndex").Value .. " v - Third if statement")  
  50.                 --     print(p.Value)          
  51.                        print("We own the pet firing remote event") 
  52.                        debounce = true         
  53.                     end            
  54.                     debounce = true        
  55.                 end                                        
  56.             end    
  57.                 wait() 
  58.                  --break
  59.                 end
  60.                    
  61.             RunTest()  
  62.           end)
  63.        end
  64.     end
  65.  
  66.     if v:IsA("ImageButton") and v.Name == "PetsGamepassButton" then -- gamepass experiment stuff
  67.         --print("not my nigga") -- script will run when player is loaded basically the for loop:)
  68.         v.MouseButton1Down:Connect(function()
  69.             if debounce and player then        
  70.             --  print("not my nigga")          
  71.             end
  72.         end)
  73.     end
  74.  
  75.     if v:IsA("ImageButton") and v.Name == "PetsHiddenButton" then -- gamepass experiment stuff
  76.         --print("not my nigga") -- script will run when player is loaded basically the for loop:)
  77.         v.MouseButton1Down:Connect(function()
  78.             if debounce and player then        
  79.                 -- if stat bla bla = true then do this bam
  80.             -- print("not my hidden nigga")        
  81.             end
  82.         end)
  83.     end
  84. end
Add Comment
Please, Sign In to add comment