Geavin

Tkaitum

Oct 22nd, 2026
10
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 12.64 KB | None | 0 0
  1. -- ============================================================================
  2. -- GLEAVIN HUB // LEVEL FARM (Background Thread Fix)
  3. -- ============================================================================
  4.  
  5. task.spawn(function()
  6. if getgenv().__GLEAVIN_LEVEL_LOADED then return end
  7. getgenv().__GLEAVIN_LEVEL_LOADED = true
  8.  
  9. -- Services
  10. local Players = game:GetService("Players")
  11. local RunService = game:GetService("RunService")
  12. local TweenService = game:GetService("TweenService")
  13. local ReplicatedStorage = game:GetService("ReplicatedStorage")
  14. local VirtualUser = game:GetService("VirtualUser")
  15. local VirtualInputManager = game:GetService("VirtualInputManager")
  16. local HttpService = game:GetService("HttpService")
  17. local Lighting = game:GetService("Lighting")
  18. local LP = Players.LocalPlayer
  19. local t = LP
  20.  
  21. local CommF = ReplicatedStorage:WaitForChild("Remotes"):WaitForChild("CommF_")
  22.  
  23. -- Safe Wait for Game Load
  24. local startWait = tick()
  25. while not (game:IsLoaded() and LP:FindFirstChild("DataLoaded")) do
  26. if tick() - startWait > 15 then break end
  27. task.wait(0.5)
  28. end
  29.  
  30. -- Settings
  31. local FolderName = "GleavinHub"
  32. if not isfolder(FolderName) then makefolder(FolderName) end
  33. local SaveFileName = FolderName .. "/LevelFarm.json"
  34.  
  35. local Settings = {}
  36. local function SaveSettings(key, value)
  37. Settings[key] = value
  38. pcall(function() writefile(SaveFileName, HttpService:JSONEncode(Settings)) end)
  39. end
  40. pcall(function() Settings = HttpService:JSONDecode(readfile(SaveFileName)) end)
  41.  
  42. -- Load Rayfield safely
  43. local Rayfield = nil
  44. local success, result = pcall(function()
  45. return loadstring(game:HttpGet('https://sirius.menu/rayfield'))()
  46. end)
  47.  
  48. if success and type(result) == "table" and result.CreateWindow then
  49. Rayfield = result
  50. else
  51. return -- Fail silently if UI can't load
  52. end
  53.  
  54. local function Notify(title, desc)
  55. pcall(function() Rayfield:Notify({ Title = title, Content = desc, Duration = 5 }) end)
  56. end
  57.  
  58. -- Core Functions
  59. local function getHRP()
  60. local c = t.Character or t.CharacterAdded:Wait()
  61. return c:FindFirstChild("HumanoidRootPart")
  62. end
  63.  
  64. getgenv().TweenManager = {
  65. currentTween = nil,
  66. CancelTweenOnly = function()
  67. if getgenv().TweenManager.currentTween then
  68. pcall(function() getgenv().TweenManager.currentTween:Cancel() end)
  69. getgenv().TweenManager.currentTween = nil
  70. end
  71. end,
  72. PlayTween = function(part, info, goal)
  73. getgenv().TweenManager.CancelTweenOnly()
  74. local tw = TweenService:Create(part, info, goal)
  75. getgenv().TweenManager.currentTween = tw
  76. tw:Play()
  77. return tw
  78. end
  79. }
  80. TweenManager = getgenv().TweenManager
  81.  
  82. function toTarget(P, skipCheck)
  83. if typeof(P) ~= "CFrame" then return end
  84. local char = t.Character
  85. if not char then return end
  86. local hrp = char:FindFirstChild("HumanoidRootPart")
  87. if not hrp then return end
  88.  
  89. if not hrp:FindFirstChild("FloatForce") then
  90. local bv = Instance.new("BodyVelocity")
  91. bv.Name = "FloatForce"
  92. bv.Velocity = Vector3.new(0, 0, 0)
  93. bv.MaxForce = Vector3.new(100000, 100000, 100000)
  94. bv.Parent = hrp
  95. end
  96.  
  97. local dist = (P.Position - hrp.Position).Magnitude
  98. if dist < (skipCheck and 8 or 150) then
  99. TweenManager.CancelTweenOnly()
  100. hrp.CFrame = P
  101. return
  102. end
  103.  
  104. local speed = Settings["Speed Tween "] or 300
  105. TweenManager.PlayTween(hrp, TweenInfo.new(dist / speed, Enum.EasingStyle.Linear), { CFrame = P })
  106. end
  107.  
  108. function equiptool(name)
  109. if name and t:FindFirstChild("Backpack") and t.Backpack:FindFirstChild(name) then
  110. t.Character.Humanoid:EquipTool(t.Backpack:FindFirstChild(name))
  111. end
  112. end
  113.  
  114. function NameWeapon(tooltip, returnTool)
  115. local function find(container)
  116. for _, item in pairs(container:GetChildren()) do
  117. if item:IsA("Tool") and item.ToolTip == tooltip then return returnTool and item or item.Name end
  118. end
  119. end
  120. return find(t.Backpack) or find(t.Character)
  121. end
  122.  
  123. function UsedualFlock() equiptool(NameWeapon(Settings["Select Weapon"] or "Melee")) end
  124.  
  125. -- Combat / Attack
  126. local G_Combat = require(ReplicatedStorage.Modules.CombatUtil)
  127. local NetMod = require(ReplicatedStorage.Modules.Net)
  128. local RegisterAttack = ReplicatedStorage.Modules.Net:WaitForChild("RE/RegisterAttack")
  129. local RegisterHit = NetMod:RemoteEvent("RegisterHit", true)
  130.  
  131. local BODY_PARTS = { RightUpperArm = true, RightLowerArm = true, RightHand = true, RightUpperLeg = true, RightLowerLeg = true, RightFoot = true, LeftUpperArm = true, LeftLowerArm = true, LeftHand = true, LeftUpperLeg = true, LeftLowerLeg = true, LeftFoot = true, UpperTorso = true, LowerTorso = true, Head = true }
  132.  
  133. local function AttackAOE(radius, includePlayers)
  134. local found, seen = {}, {}
  135. local origins = { t.Character.HumanoidRootPart }
  136. -- Simplified hit detection for stability
  137. for _, mob in pairs(workspace.Enemies:GetChildren()) do
  138. if mob:FindFirstChild("HumanoidRootPart") and mob.Humanoid.Health > 0 then
  139. if (mob.HumanoidRootPart.Position - origins[1].Position).Magnitude <= radius + 15 then
  140. table.insert(found, { mob, mob.HumanoidRootPart })
  141. end
  142. end
  143. end
  144. return #found > 0 and found or nil
  145. end
  146.  
  147. function attackMelee(radius)
  148. local tool = t.Character:FindFirstChildOfClass("Tool")
  149. if not tool then return end
  150. local hits = AttackAOE(radius, false)
  151. if not hits then return end
  152.  
  153. local anims = G_Combat:GetMovesetAnimCache(t.Character.Humanoid)
  154. if anims then
  155. RegisterAttack:FireServer(0)
  156. RegisterHit:FireServer(table.remove(hits, 1)[2], hits)
  157. end
  158. end
  159.  
  160. function AttackFunction(radius)
  161. if t.Character.Stun.Value ~= 0 then return end
  162. attackMelee(radius)
  163. end
  164.  
  165. function ClickM1(mob, isBoat)
  166. if not mob or not mob:FindFirstChild("HumanoidRootPart") then return end
  167. if Settings["Select Weapon"] == "Blox Fruit" then
  168. local fruitTool = t.Character:FindFirstChild(NameWeapon("Blox Fruit"))
  169. if fruitTool and fruitTool:FindFirstChild("LeftClickRemote") then
  170. local lookDir = (mob.HumanoidRootPart.Position - t.Character.HumanoidRootPart.Position).Unit
  171. fruitTool.LeftClickRemote:FireServer(lookDir, math.random(1, 5))
  172. return
  173. end
  174. end
  175. AttackFunction(isBoat and 80 or 30)
  176. end
  177.  
  178. -- Fast Attack
  179. local CombatFrameworkR = nil
  180. pcall(function()
  181. local cfMod = require(t.PlayerScripts:WaitForChild("CombatFramework"))
  182. local ups = getupvalues or (debug and debug.getupvalues)
  183. CombatFrameworkR = ups and ups(cfMod) and ups(cfMod)[2]
  184. end)
  185.  
  186. task.spawn(function()
  187. while task.wait() do
  188. if getgenv().Usefastattack and CombatFrameworkR and CombatFrameworkR.activeController then
  189. pcall(function()
  190. local c = CombatFrameworkR.activeController
  191. c.hitboxMagnitude = 60
  192. c.timeToNextAttack = 0
  193. c.attacking = false
  194. if c.attack then c:attack() end
  195. end)
  196. end
  197. end
  198. end)
  199.  
  200. -- Mob Detection
  201. function IsMobAlive(mob)
  202. return mob and mob.Parent and mob:FindFirstChild("HumanoidRootPart") and mob.Humanoid.Health > 0
  203. end
  204.  
  205. function DetectMob(nameOrList)
  206. local best, bestDist = nil, math.huge
  207. for _, mob in pairs(workspace.Enemies:GetChildren()) do
  208. if (typeof(nameOrList) == "table" and table.find(nameOrList, mob.Name) or mob.Name == nameOrList) and IsMobAlive(mob) then
  209. local d = (mob.HumanoidRootPart.Position - t.Character.HumanoidRootPart.Position).Magnitude
  210. if d < bestDist then bestDist, best = d, mob end
  211. end
  212. end
  213. return best
  214. end
  215.  
  216. function sizepart(mob)
  217. if t:DistanceFromCharacter(mob.HumanoidRootPart.Position) <= 50 then
  218. for _, part in pairs(mob:GetDescendants()) do if part:IsA("BasePart") and part.CanCollide then part.CanCollide = false end end
  219. end
  220. end
  221.  
  222. -- Quest Logic (Simplified for stability)
  223. function TakeQuestLevel()
  224. -- Minimal quest taker
  225. local quests = {
  226. {lvl = 1, name = "Bandit", quest = "BanditQuest1", id = 1},
  227. {lvl = 10, name = "Monkey", quest = "JungleQuest", id = 1},
  228. {lvl = 15, name = "Gorilla", quest = "JungleQuest", id = 2},
  229. {lvl = 30, name = "Pirate", quest = "BuggyQuest1", id = 1},
  230. {lvl = 60, name = "Desert Bandit", quest = "DesertQuest", id = 1},
  231. {lvl = 90, name = "Snow Bandit", quest = "SnowQuest", id = 1},
  232. {lvl = 120, name = "Chief Petty Officer", quest = "MarineQuest2", id = 1},
  233. {lvl = 150, name = "Sky Bandit", quest = "SkyQuest", id = 1},
  234. }
  235. local currentLvl = t.Data.Level.Value
  236. local target = nil
  237. for _, q in ipairs(quests) do if currentLvl >= q.lvl then target = q end end
  238. if target then
  239. CommF:InvokeServer("StartQuest", target.quest, target.id)
  240. end
  241. end
  242.  
  243. -- Main Farm Loop
  244. function FarmMethod()
  245. if not t.PlayerGui.Main.Quest.Visible then
  246. TakeQuestLevel()
  247. task.wait(1)
  248. return
  249. end
  250.  
  251. local questTitle = t.PlayerGui.Main.Quest.Container.QuestTitle.Title.Text
  252. local mobName = ""
  253. -- Extract mob name from quest title (e.g. "Defeat 5 [Bandit]")
  254. for word in string.gmatch(questTitle, "%[([^%]]+)%]") do mobName = word end
  255. if mobName == "" then mobName = string.match(questTitle, "Defeat %d+ (.*)") end
  256. if not mobName or mobName == "" then return end
  257.  
  258. local mob = DetectMob(mobName)
  259. if mob then
  260. repeat
  261. task.wait()
  262. if not IsMobAlive(mob) then break end
  263. sizepart(mob)
  264. UsedualFlock()
  265.  
  266. if Settings["Select Weapon"] == "Blox Fruit" then
  267. toTarget(mob.HumanoidRootPart.CFrame * CFrame.new(-7, 20, 0))
  268. else
  269. toTarget(mob.HumanoidRootPart.CFrame * CFrame.new(7, 20, 0))
  270. end
  271. ClickM1(mob)
  272. until not IsMobAlive(mob) or not Settings["Start Farm"]
  273. else
  274. -- If no mob found, just wait a moment
  275. task.wait(1)
  276. end
  277. end
  278.  
  279. task.spawn(function()
  280. while task.wait(0.1) do
  281. if Settings["Start Farm"] then
  282. pcall(FarmMethod)
  283. end
  284. end
  285. end)
  286.  
  287. -- UI Setup
  288. local Window = Rayfield:CreateWindow({
  289. Name = "Gleavin Hub // Level Farm",
  290. LoadingTitle = "Gleavin Hub",
  291. LoadingSubtitle = "Level Farm",
  292. Theme = "Default",
  293. KeySystem = false,
  294. })
  295.  
  296. local FarmTab = Window:CreateTab("Farm", 4483362458)
  297. FarmTab:CreateSection("Main Controls")
  298. FarmTab:CreateToggle({ Name = "Start Farm", CurrentValue = Settings["Start Farm"] or false, Flag = "StartFarmFlag", Callback = function(v) Settings["Start Farm"] = v; SaveSettings("Start Farm", v) end })
  299. FarmTab:CreateDropdown({ Name = "Select Weapon", Options = { "Melee", "Sword", "Blox Fruit" }, CurrentOption = Settings["Select Weapon"] or "Melee", MultipleOptions = false, Flag = "WeaponFlag", Callback = function(v) Settings["Select Weapon"] = type(v) == "table" and v[1] or v end })
  300. FarmTab:CreateToggle({ Name = "Fast Attack", CurrentValue = getgenv().Usefastattack or false, Flag = "FastAttackFlag", Callback = function(v) getgenv().Usefastattack = v end })
  301. FarmTab:CreateSlider({ Name = "Speed Tween", Range = { 0, 1000 }, Increment = 10, Suffix = "studs/s", CurrentValue = Settings["Speed Tween "] or 300, Flag = "SpeedTweenFlag", Callback = function(v) Settings["Speed Tween "] = v; SaveSettings("Speed Tween ", v) end })
  302.  
  303. Rayfield:LoadConfiguration()
  304. Notify("Gleavin Hub", "Level Farm loaded successfully")
  305. end)
Advertisement
Add Comment
Please, Sign In to add comment