qsenko1

PetFrame names like auto selector thingy!!

Jun 23rd, 2021
177
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 4.55 KB | None | 0 0
  1.  -- all this is inside one local script used for over 33 Frames:O
  2. local RS = game:GetService("ReplicatedStorage") -- the actual Service in what we have all the Pets,Events stored and etc.
  3. local PetsFolder = RS.Pets
  4. local PetsFrameEvent = PetsFolder.PetEvents.PetFrame -- the event that we need for the purchase frame to pop up
  5. local HiddenPetEvent = PetsFolder.PetEvents.HiddenPetEvent
  6. local MainFrame = script.Parent -- the frame that we will use to loop and get all objects,("instances") from!!!
  7. 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!!
  8. local player = game:GetService("Players").LocalPlayer -- thats a easy way of getting the local Player
  9.  
  10. for i,v in pairs(MainFrame:GetDescendants())do
  11.    
  12.     if v:IsA("ImageButton") and v.Name == "PetsButton" then -- checks if theres a image button and its name is equal to "PetsButton"
  13.        
  14.         v.MouseButton1Down:Connect(function() -- this function will fire if the requirments above are true!!   
  15.         if debounce and player then -- check if debounce is true theres a player , this is optimal tho,not nessesary
  16.             if player.leaderstats.Coins.Value >= v.Price.Value then -- checks if the player has Coins
  17.             debounce = false
  18.         --  print("hi my nigga") -- prints once
  19.             --wait(.1)             
  20.             PetsFrameEvent:FireServer() -- Fires from client to server to check if the player owns the pet or not:P(Fires once)        
  21.             debounce = true
  22.             else -- if player doesnt have enough Coins then the RemoteEvent above wont execute and this will!!
  23.                 v.PetPriceCheck.Text = "Not Enough Coins"
  24.                 wait(1)
  25.                 v.PetPriceCheck.Text = v.Price.Value .. " Coins" -- resets the price to its default per pet
  26.                 end
  27.             end
  28.         end)
  29.     end
  30.    
  31.     if v:IsA("ImageButton") and v.Name == "PetsGamepassButton" then -- gamepass experiment stuff
  32.         --print("not my nigga") -- script will run when player is loaded basically the for loop:)
  33.         v.MouseButton1Down:Connect(function()
  34.             if debounce and player then
  35.                
  36.                 print("not my nigga")
  37.                
  38.             end
  39.         end)
  40.     end
  41.    
  42.     if v:IsA("ImageButton") and v.Name == "PetsHiddenButton" then -- gamepass experiment stuff
  43.         --print("not my nigga") -- script will run when player is loaded basically the for loop:)
  44.         v.MouseButton1Down:Connect(function()
  45.             if debounce and player then        
  46.             -- if stat bla bla = true then do this bam
  47.             print("not my hidden nigga")
  48.                
  49.             end
  50.         end)
  51.     end
  52. end
  53.  
  54. PetsFrameEvent.OnClientEvent:Connect(function(Index) -- when the remote event on the server fires 15 times for no reason it receives the info in here once and i wanted it once:P,but thats a small but i need to figure out in future!!
  55.     if debounce then
  56.        
  57.     local Player = game:GetService("Players").LocalPlayer
  58.            
  59.     for i,v in pairs(MainFrame:GetDescendants())do
  60.             --v:GetChildren()
  61.             --print(v)
  62.             if v:IsA("ImageButton") and v.Name == "PetsButton" then        
  63.                 v.Activated:Connect(function(Index)            
  64.                
  65.                 debounce = false   
  66.                
  67.                 print(v)
  68.                
  69.                 local Frame = player:FindFirstChild("PlayerGui"):FindFirstChild("PetsPurchaseGui"):FindFirstChild("BuyPet")    
  70.                 local FrameInfo = Frame:FindFirstChild("Desc")
  71.                 local PetName = v:FindFirstChild("PetIndex").Value
  72.                 local PetPrice = v:FindFirstChild("Price").Value
  73.                 print(PetName)         
  74.                 wait()         
  75.                 FrameInfo.Text = "Are you Sure you want to buy this " .. PetName .. " for " .. PetPrice .. " Coins"
  76.                
  77.                 Frame:TweenPosition(
  78.                     UDim2.new(0.499, 0,0.494, 0),-- End Position       
  79.                     "Out", -- Easing Direction
  80.                     "Linear", -- Easing Style
  81.                     .5 -- Time in Seconds
  82.                 )  
  83.                
  84.             Frame.Visible = true                   
  85.            end)
  86.         end        
  87.     end
  88.     wait(2)
  89.    
  90.         debounce = true
  91.     end
  92. end)
  93.                                  --From Below this line is the stuff inside the serve script same checks for idk it shoudnt even matter cause its locally but yeah!!
  94.  
  95. PetsFrameEvent.OnServerEvent:Connect(function(player)
  96.     local MainFrame = player.PlayerGui.MusicGui.ShopFrame.ShopFrame2.ScrollingFrame
  97. for i,v in pairs(MainFrame:GetDescendants()) do    
  98.     if v:IsA("ImageButton") and v.Name == "PetsButton" and debounce and player then    
  99.     if player.leaderstats.Coins.Value >= v:FindFirstChild("Price").Value then  
  100.             debounce = false                                   
  101.             PetsFrameEvent:FireClient(player)-- for some stupid reason it fires 15 times tho its super fast but on client he get the info once so its a good thing i guess!!
  102.         --  print("not nigga") 
  103.             --wait(.1)
  104.             debounce = true    
  105.           end
  106.        end
  107.     end
  108. end)
  109.                    -- In the end i saw Bermuda Triangle client,server,client:D
Add Comment
Please, Sign In to add comment