qsenko1

Unfinished Pets Local Check Code thing:d

Jun 21st, 2021
161
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.85 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 MainFrame = script.Parent -- the frame that we will use to loop and get all objects,("instances") from!!!
  5. 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!!
  6. local Player = game:GetService("Players").LocalPlayer -- thats a easy way of getting the local Player
  7.  
  8. for i,v in pairs(MainFrame:GetDescendants())do
  9.    
  10.     if v:IsA("ImageButton") and v.Name == "PetsButton" then -- checks if theres a image button and its name is equal to "PetsButton"
  11.        
  12.         v.MouseButton1Down:Connect(function() -- this function will fire if the requirments above are true!!   
  13.         if debounce and Player then -- check if debounce is true theres a player , this is optimal tho,not nessesary
  14.             if Player.leaderstats.Coins.Value >= v.Price.Value then -- checks if the player has Coins
  15.             debounce = false
  16.             print("hi my nigga")
  17.             wait(.1)
  18.             PetsFrameEvent:FireServer() -- Fires from client to server to check if the player owns the pet or not:P
  19.             debounce = true
  20.             else -- if player doesnt have enough Coins then the RemoteEvent above wont execute and this will!!
  21.                 v.PetPriceCheck.Text = "Not Enough Coins"
  22.                 wait(1)
  23.                 v.PetPriceCheck.Text = v.Price.Value .. " Coins" -- resets the price to its default per pet
  24.                 end
  25.             end
  26.         end)
  27.     end
  28.    
  29.     if v:IsA("ImageButton") and v.Name == "PetsGamepassButton" then -- gamepass experiment stuff
  30.         --print("not my nigga") -- script will run when player is loaded basically the for loop:)
  31.         v.MouseButton1Down:Connect(function()
  32.            
  33.             print("not my nigga")
  34.            
  35.         end)
  36.     end
  37. end
Add Comment
Please, Sign In to add comment