Advertisement
Guest User

sb2 inject farm script

a guest
Jan 6th, 2018
3,921
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 4.87 KB | None | 0 0
  1. function log(text)
  2.     print("Hijacked Yuno: "..text)
  3. end
  4.  
  5. _G.rpcKey = {"‰","®","þ","÷"}
  6. local F = game:GetService("ReplicatedStorage"):WaitForChild("Function")
  7. _G.cKeys = F:InvokeServer("Combat", _G.rpcKey, {"RefillKeys", "00"})
  8. local t = 0 -- Tries for attacking
  9. local lHp = 999999999
  10. local dly = 0.2
  11.  
  12. log("Loading.")
  13.  
  14. while wait(.125)do
  15.     if _G.cKeys == nil then _G.cKeys = F:InvokeServer("Combat", _G.rpcKey, {"RefillKeys", "00"}) else break end
  16. end
  17.  
  18. log("Found Keys.")
  19.  
  20. -- Statistic Data
  21. local player = game:GetService("Players").LocalPlayer
  22. local vl = game.ReplicatedStorage.Profiles[player.Name].Stats.Vel.Value
  23. local kls = 0
  24. local st
  25.  
  26. local bosses = {}
  27. bosses[0] = "" -- No mobs on floor 0
  28. bosses[1] = "Thief King"
  29. bosses[2] = "Borik The BeeKeeper"
  30. bosses[3] = "Ice King"
  31. bosses[4] = "the Lion"
  32. bosses[5] = "Centurian Chieftain"
  33. bosses[6] = "" -- No mobs on floor 6
  34.  
  35. local mobs = {}
  36. mobs[0] = {} -- no mobs
  37. mobs[1] = {}
  38. mobs[2] = {}
  39. mobs[3] = {}
  40. mobs[4] = {}
  41. mobs[5] = {}
  42. mobs[6] = {} -- no mobs
  43.  
  44. local ign = {}
  45. ign[0] = {} -- no mobs
  46. ign[1] = {}
  47. ign[2] = {"Leaf Beetle", "Wasp", "Giant Ruins Hornet"}
  48. ign[3] = {}
  49. ign[4] = {}
  50. ign[5] = {}
  51. ign[6] = {} -- no mobs
  52.  
  53. local f = 3 -- Floor, adjust to floor.
  54.  
  55. --function runForLife()
  56. --  for _,v in pairs(game:GetService("Players"):GetChildren()) do if v:GetRankInGroup(2986019) ~= 0 then return false end end -- If in the Swordburst 2 group then run!
  57. --  return true
  58. --end
  59.  
  60. player.Idled:connect(function(time)
  61.     print("idle for " .. time .. " seconds")
  62.     if player.Character then player.Character.Humanoid.Jump = true end
  63. end)
  64.  
  65. function refillCKeys()
  66.     local newKey = nil
  67.     if #_G.cKeys <= 0 then newKey = "00" else newKey = _G.cKeys[#_G.cKeys] table.remove(_G.cKeys, #_G.cKeys) end   
  68.  
  69.     local new = game.ReplicatedStorage.Function:InvokeServer("Combat", _G.rpcKey, {"RefillKeys", newKey})
  70.     if new then for i, v in ipairs(new) do table.insert(_G.cKeys, v) end end
  71. end
  72.  
  73. function _G.getCombatKey()
  74.     if #_G.cKeys <= 0 then return -1 end
  75.     local newKey = _G.cKeys[#_G.cKeys]
  76.     table.remove(_G.cKeys, #_G.cKeys)
  77.     if #_G.cKeys < 15 then spawn(refillCKeys) end
  78.     return newKey
  79. end
  80.  
  81. -- check for { "Torso", "HumanoidRootPart", "Entity", "HealthPos" }
  82. function validate(m, t)
  83.     if (not player.Character) or player.Character.Humanoid.Health <= 0 then return false end
  84.     if t >= 5 then return false end
  85.     for _,v in pairs(ign[f]) do if string.match(m.Name, v) then return false end end
  86.     --for _,v in pairs(mobs[f]) do if not string.match(m.Name, v) then return false end    
  87.     if m.HumanoidRootPart and m.Entity and m.HealthPos and m.Entity.Health and m.Entity.Health.Value > 0 then else return false end
  88.     --if runForLife() == true then return false end
  89.     return true
  90. end
  91.  
  92. function rOffset()
  93.     return Vector3.new(0, 4, 0)
  94. end
  95.  
  96. function gBoss(b)
  97.     for _,v in pairs(game.Workspace.Mobs:GetChildren()) do if string.match(v.Name, bosses[f]) then return v end end
  98.     return b
  99. end
  100.  
  101. function deb(m)
  102.     print("Debugging Monster: "..m.Name.." ("..#m:GetChildren().." Parts.)")
  103.     for _,v in pairs(m:GetChildren()) do print("Child -> "..v.Name.." ("..v.ClassName..")") end
  104.     print("------------------------------")
  105. end
  106.  
  107. function atkMob(v)
  108.     while wait(dly) and validate(v, t) do
  109.         if _G.deb1 then deb(v) end
  110.         player.Character:FindFirstChild("HumanoidRootPart").CFrame = CFrame.new(v.HumanoidRootPart.Position + rOffset())
  111.         game.ReplicatedStorage.Event:FireServer("Combat", _G.rpcKey, { "Attack", nil, v, _G.getCombatKey() })
  112.         local vH = v.Entity.Health.Value
  113.         t = (vH ~= v.Entity.Health.MaxValue and vH < lHp) and 0 or t + 1
  114.         lHp = vH
  115.     end
  116.     lHp = 99999999999
  117.     kls = kls + 1
  118. end
  119.  
  120. _G.runBot = true
  121.  
  122. function farm()
  123.     st = os.time()
  124.     _G.bSpawn = false
  125.  
  126.     workspace.Mobs.ChildAdded:connect(function(m)
  127.         if string.match(m.Name, bosses[f]) then _G.bSpawn = true end
  128.     end)
  129.    
  130.     game:GetService("RunService").RenderStepped:connect(function()
  131.         if player.Character and not player.Character:FindFirstChild("IgnoreTeleport") then local ff = Instance.new("IntValue", player.Character) ff.Name = "IgnoreTeleport" end
  132.     end)
  133.  
  134.     game:GetService("RunService").RenderStepped:connect(function() -- Kicked for teleporting if this is not included.
  135.         if player.Character and player.Character.Parent and player.Character:FindFirstChild("Humanoid") and player.Character:FindFirstChild("HumanoidRootPart") then
  136.             player.Character.Humanoid.WalkSpeed = 9999999
  137.         end
  138.     end)
  139.  
  140.     while wait() and _G.runBot do
  141.         for _, v in pairs(game.Workspace.Mobs:GetChildren()) do
  142.             if (validate(v, t))then
  143.                 if ((os.time() - st) / 60) % 2 == 0 then log("Kills: "..kls.." Vel:"..(game.ReplicatedStorage.Profiles[player.Name].Stats.Vel.Value - vl).." in "..(os.time() - st).."seconds") end -- Every 2min
  144.                 atkMob((_G.bSpawn) and gBoss(v) or v)          
  145.                 _G.bSpawn = (_G.bSpawn) and false or _G.bSpawn
  146.                 t = 0
  147.             end
  148.         end
  149.     end
  150. end
  151.  
  152. log("Starting farm...")
  153. farm()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement