Advertisement
BOT_Script

Untitled

Nov 26th, 2022
523
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 6.04 KB | None | 0 0
  1. local Workspace = game:GetService("Workspace")
  2. local ReplicatedStorage = game:GetService("ReplicatedStorage")
  3. local Players = game:GetService("Players")
  4. local TS = game:GetService('TweenService')
  5. local UserInputService = game:GetService("UserInputService")
  6.  
  7. local Player = Players.LocalPlayer
  8.  
  9. local screenGui = script.Parent
  10.  
  11. local EggsFolder = workspace.Eggs
  12. local PetModels = ReplicatedStorage.Pets
  13.  
  14. local EggConfig = require(ReplicatedStorage.Config.Eggs)
  15.  
  16. local BuyEgg = ReplicatedStorage.Remotes.BuyEgg
  17. local PetHatched = ReplicatedStorage.Remotes.PetHatched
  18.  
  19. local formatNumber = require(ReplicatedStorage:WaitForChild("Libs"):WaitForChild("FormatNumber"))
  20.  
  21. local Template = script.Parent.Template
  22.  
  23. local auto = false
  24.  
  25. local function GenerateViewportFrame(viewportFrame: ViewportFrame, petModel: Model)
  26.     petModel:SetPrimaryPartCFrame(CFrame.new()* CFrame.Angles(0, math.rad(90), 0))
  27.     petModel.Parent = viewportFrame
  28.    
  29.     local camera = Instance.new("Camera", viewportFrame)
  30.     viewportFrame.CurrentCamera = camera
  31.    
  32.     camera.CFrame = CFrame.new(Vector3.new(0,0,1.5), petModel.PrimaryPart.Position)
  33. end
  34.  
  35. local function GeneratePet(container: Frame, petConfig: table)
  36.     local clone = container.Template:Clone()
  37.     if petConfig.See == true then
  38.         clone.Parent = container
  39.         clone.Name = petConfig.ID
  40.         clone.Visible = true
  41.         clone.PetChance.Text = formatNumber.FormatCompact(petConfig.Chance).."%"
  42.         clone.PetRarity.Text = petConfig.Rarity
  43.         if petConfig.Rarity == "Common" then
  44.             clone.PetRarity.TextColor3 = Color3.fromRGB(255, 255, 255)
  45.         elseif petConfig.Rarity == "Uncommon" then
  46.             clone.PetRarity.TextColor3 = Color3.fromRGB(10, 255, 79)
  47.         elseif petConfig.Rarity == "Rare" then
  48.             clone.PetRarity.TextColor3 = Color3.fromRGB(33, 92, 255)
  49.         elseif petConfig.Rarity == "Epic" then
  50.             clone.PetRarity.TextColor3 = Color3.fromRGB(170, 0, 255)
  51.         elseif petConfig.Rarity == "Legendary" then
  52.             clone.PetRarity.UIGradient.Enabled = true
  53.         elseif petConfig.Rarity == "Secret" then
  54.             clone.PetRarity.UIGradient.Enabled = true
  55.         elseif petConfig.Rarity == "God" then
  56.             clone.PetRarity.UIGradient.Enabled = true
  57.         end
  58.     else
  59.         -- nothing
  60.     end
  61.    
  62.     local petClone = PetModels[petConfig.ID]:Clone()
  63.     GenerateViewportFrame(clone.ViewportFrame, petClone)
  64. end
  65.  
  66. local function RequestHatch(eggId: string, action: string)
  67.     if action == "Auto" then
  68.         BuyEgg:FireServer(eggId, "Auto")
  69.     elseif action == "x1" then
  70.         BuyEgg:FireServer(eggId)
  71.     elseif action == "x3" then
  72.         BuyEgg:FireServer(eggId, "x3")
  73.     end
  74. end
  75.  
  76. local function GenerateBillboardGui(eggModel: Instance, eggConfig: table)
  77.     local attachment = eggModel.Attachment
  78.     local clone = Template:Clone()
  79.     clone.Parent = script.Parent
  80.     clone.Adornee = attachment
  81.     clone.Name = eggModel.Name
  82.    
  83.     clone.Frame.Title.Text = eggModel.Name:gsub("_"," ")
  84.     clone.Frame.Price.Price.Text = eggConfig.Price
  85.    
  86.     for _, pet in ipairs(eggConfig.Pets) do
  87.         GeneratePet(clone.Frame.Container, pet)
  88.     end
  89.    
  90.     clone.Frame.Buttons.Auto.MouseButton1Click:Connect(function()
  91.         for _, egg in ipairs(EggsFolder:GetChildren()) do
  92.             local distanceBetween = (Player.Character.PrimaryPart.Position - egg.Position).Magnitude
  93.             if distanceBetween > 10 then
  94.                 auto = true
  95.                 if auto == true then
  96.                     while auto == true do
  97.                         if Player.gamepasses.Triple_Hatch.Value then
  98.                             RequestHatch(eggModel.Name, "x3")
  99.                         elseif not Player.gamepasses.Triple_Hatch.Value then
  100.                             RequestHatch(eggModel.Name, "Auto")
  101.                         end
  102.                         wait(2)
  103.                         if distanceBetween > 15 then
  104.                             auto = false
  105.                         end
  106.                     end
  107.                    
  108.                 end
  109.             end
  110.         end
  111.        
  112.     end)
  113.    
  114.     clone.Frame.Buttons.x1.MouseButton1Click:Connect(function()
  115.         if auto == false then
  116.             RequestHatch(eggModel.Name, "x1")
  117.         else
  118.             auto = false
  119.         end
  120.  
  121.     end)
  122.     clone.Frame.Buttons.x3.MouseButton1Click:Connect(function()
  123.         if not Player.gamepasses.Triple_Hatch.Value then           
  124.             game:GetService("MarketplaceService"):PromptGamePassPurchase(Player, 105405980)
  125.         else
  126.             if auto == false then
  127.                 RequestHatch(eggModel.Name, "x3")
  128.             else
  129.                 auto = false
  130.             end
  131.            
  132.         end
  133.     end)
  134. end
  135.  
  136. for eggName, eggConfig in pairs(EggConfig) do
  137.     GenerateBillboardGui(EggsFolder[eggName], eggConfig)
  138. end
  139.  
  140. local function hatchOne(pet, egg)
  141.     local eggMesh = egg:FindFirstChild()
  142. end
  143.  
  144. local function GetClosestEgg()
  145.     local closest = {Egg = nil, Distance = 9_999}
  146.     for _, egg in ipairs(EggsFolder:GetChildren()) do
  147.         local distanceBetween = (Player.Character.PrimaryPart.Position - egg.Position).Magnitude
  148.        
  149.         if distanceBetween > 15 then continue end
  150.        
  151.         if closest.Distance > distanceBetween then
  152.             closest = {Egg = egg.Name, Distance = distanceBetween}
  153.         end
  154.     end
  155.     return closest.Egg
  156. end
  157.  
  158. UserInputService.InputEnded:Connect(function(input: InputObject, gameProcessedEvent: boolean)
  159.     if gameProcessedEvent then return end
  160.     if not input.UserInputType == Enum.UserInputType.Keyboard then return end
  161.    
  162.     local eggId = GetClosestEgg()
  163.     if not eggId then return end
  164.    
  165.     if input.KeyCode == Enum.KeyCode.T then
  166.         RequestHatch(eggId, "x3")
  167.     elseif input.KeyCode == Enum.KeyCode.R then
  168.         RequestHatch(eggId, "Auto")
  169.     elseif input.KeyCode == Enum.KeyCode.E then
  170.         RequestHatch(eggId, "x1")
  171.     end
  172. end)
  173.  
  174. PetHatched.OnClientEvent:Connect(function(pet: table)
  175.     local Rainbow = {{0, 255, 0}, {255, 0, 0}}
  176.     print(pet.Rarity.." "..pet.ID)
  177.     if pet.Rarity == "God" then
  178.         game.StarterGui:SetCore("ChatMakeSystemMessage", {Text = "Someone has hatched a pet "..pet.ID:gsub("_"," ").." GOD "..pet.Chance.."%", Color = Color3.fromRGB(170, 85, 255), Font = Enum.Font.FredokaOne})
  179.     elseif pet.Rarity == "Lengedary" then
  180.         game.StarterGui:SetCore("ChatMakeSystemMessage", {Text = "Someone has hatched a pet "..pet.ID:gsub("_"," ").." Legendary "..pet.Chance.."%", Color = Color3.fromRGB(85, 255, 0), Font = Enum.Font.FredokaOne})
  181.     elseif pet.Rarity == "Secret" then
  182.         game.StarterGui:SetCore("ChatMakeSystemMessage", {Text = "Someone has hatched a pet "..pet.ID:gsub("_"," ").." Secret "..pet.Chance.."%", Color = Color3.fromRGB(0, 85, 255), Font = Enum.Font.FredokaOne})
  183.  
  184.     end
  185. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement