qsenko1

Kinda Working but super annoying problem

Jun 24th, 2021 (edited)
462
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.87 KB | None | 0 0
  1. local RS = game:GetService("ReplicatedStorage")
  2. local PetsFolder = RS.Pets
  3. local PetsFrameEvent = PetsFolder.PetEvents.PetFrame
  4. local MainFrame = script.Parent
  5. local debounce = true
  6. local player = game:GetService("Players").LocalPlayer
  7. local PetValues = player.PetsFolder.Values:GetChildren()
  8. wait()
  9. for i,v in pairs(MainFrame:GetDescendants())do
  10.     if v:IsA("ImageButton") and v.Name == "PetsButton" then    
  11.         v.MouseButton1Down:Connect(function()            
  12.             local function RunTest()
  13.             for i,p in ipairs(PetValues)do                                  
  14.           --print(p)
  15.             print(p.Value)        
  16.         if p:IsA("BoolValue") then        
  17.             if debounce and player then    
  18.                debounce = false    
  19.                local PetIsName = v:FindFirstChild("PetIndex").Value  
  20.                  -- print(PetIsName)
  21.                  -- p = PetIsName
  22.                     print(p)
  23.                  -- print(p.Value)
  24.                     if p.Value == false and player.leaderstats.Coins.Value >= v.Price.Value then -- and p[PetIsName]
  25.                     local Frame = player:FindFirstChild("PlayerGui"):FindFirstChild("PetsPurchaseGui"):FindFirstChild("BuyPet")        
  26.                     local FrameInfo = Frame:FindFirstChild("Desc")
  27.                     local PetName = v:FindFirstChild("PetIndex").Value
  28.                     local PetPrice = v:FindFirstChild("Price").Value        
  29.                     --print(PetName)                        
  30.                     FrameInfo.Text = "Are you Sure you want to buy this " .. PetName .. " for " .. PetPrice .. " Coins"            
  31.                     Frame:TweenPosition(
  32.                         UDim2.new(0.499, 0,0.494, 0),-- End Position        
  33.                         "Out", -- Easing Direction
  34.                         "Linear", -- Easing Style
  35.                         .5 -- Time in Seconds
  36.                     )    
  37.                        Frame.Visible = true                          
  38.       elseif p.Value == false and player.leaderstats.Coins.Value < v.Price.Value then                        
  39.                        v.PetPriceCheck.Text = "Not Enough Coins"
  40.                        wait(1)
  41.                        v.PetPriceCheck.Text = v.Price.Value .. " Coins"      
  42.      elseif p.Value == true and player.leaderstats.Coins.Value >= v.Price.Value or player.leaderstats.Coins.Value < v.Price.Value then
  43.                        print("We own the pet firing remote event")          
  44.                     end                
  45.                     debounce = true            
  46.                 end                                            
  47.             end        
  48.                 wait()    
  49.                  --break
  50.                 end    
  51.             end            
  52.             RunTest()    
  53.             --return
  54.         end)    
  55.         --wait(1)            
  56.     end
Add Comment
Please, Sign In to add comment