Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- ============================================================================
- -- GLEAVIN HUB // LEVEL FARM (Background Thread Fix)
- -- ============================================================================
- task.spawn(function()
- if getgenv().__GLEAVIN_LEVEL_LOADED then return end
- getgenv().__GLEAVIN_LEVEL_LOADED = true
- -- Services
- local Players = game:GetService("Players")
- local RunService = game:GetService("RunService")
- local TweenService = game:GetService("TweenService")
- local ReplicatedStorage = game:GetService("ReplicatedStorage")
- local VirtualUser = game:GetService("VirtualUser")
- local VirtualInputManager = game:GetService("VirtualInputManager")
- local HttpService = game:GetService("HttpService")
- local Lighting = game:GetService("Lighting")
- local LP = Players.LocalPlayer
- local t = LP
- local CommF = ReplicatedStorage:WaitForChild("Remotes"):WaitForChild("CommF_")
- -- Safe Wait for Game Load
- local startWait = tick()
- while not (game:IsLoaded() and LP:FindFirstChild("DataLoaded")) do
- if tick() - startWait > 15 then break end
- task.wait(0.5)
- end
- -- Settings
- local FolderName = "GleavinHub"
- if not isfolder(FolderName) then makefolder(FolderName) end
- local SaveFileName = FolderName .. "/LevelFarm.json"
- local Settings = {}
- local function SaveSettings(key, value)
- Settings[key] = value
- pcall(function() writefile(SaveFileName, HttpService:JSONEncode(Settings)) end)
- end
- pcall(function() Settings = HttpService:JSONDecode(readfile(SaveFileName)) end)
- -- Load Rayfield safely
- local Rayfield = nil
- local success, result = pcall(function()
- return loadstring(game:HttpGet('https://sirius.menu/rayfield'))()
- end)
- if success and type(result) == "table" and result.CreateWindow then
- Rayfield = result
- else
- return -- Fail silently if UI can't load
- end
- local function Notify(title, desc)
- pcall(function() Rayfield:Notify({ Title = title, Content = desc, Duration = 5 }) end)
- end
- -- Core Functions
- local function getHRP()
- local c = t.Character or t.CharacterAdded:Wait()
- return c:FindFirstChild("HumanoidRootPart")
- end
- getgenv().TweenManager = {
- currentTween = nil,
- CancelTweenOnly = function()
- if getgenv().TweenManager.currentTween then
- pcall(function() getgenv().TweenManager.currentTween:Cancel() end)
- getgenv().TweenManager.currentTween = nil
- end
- end,
- PlayTween = function(part, info, goal)
- getgenv().TweenManager.CancelTweenOnly()
- local tw = TweenService:Create(part, info, goal)
- getgenv().TweenManager.currentTween = tw
- tw:Play()
- return tw
- end
- }
- TweenManager = getgenv().TweenManager
- function toTarget(P, skipCheck)
- if typeof(P) ~= "CFrame" then return end
- local char = t.Character
- if not char then return end
- local hrp = char:FindFirstChild("HumanoidRootPart")
- if not hrp then return end
- if not hrp:FindFirstChild("FloatForce") then
- local bv = Instance.new("BodyVelocity")
- bv.Name = "FloatForce"
- bv.Velocity = Vector3.new(0, 0, 0)
- bv.MaxForce = Vector3.new(100000, 100000, 100000)
- bv.Parent = hrp
- end
- local dist = (P.Position - hrp.Position).Magnitude
- if dist < (skipCheck and 8 or 150) then
- TweenManager.CancelTweenOnly()
- hrp.CFrame = P
- return
- end
- local speed = Settings["Speed Tween "] or 300
- TweenManager.PlayTween(hrp, TweenInfo.new(dist / speed, Enum.EasingStyle.Linear), { CFrame = P })
- end
- function equiptool(name)
- if name and t:FindFirstChild("Backpack") and t.Backpack:FindFirstChild(name) then
- t.Character.Humanoid:EquipTool(t.Backpack:FindFirstChild(name))
- end
- end
- function NameWeapon(tooltip, returnTool)
- local function find(container)
- for _, item in pairs(container:GetChildren()) do
- if item:IsA("Tool") and item.ToolTip == tooltip then return returnTool and item or item.Name end
- end
- end
- return find(t.Backpack) or find(t.Character)
- end
- function UsedualFlock() equiptool(NameWeapon(Settings["Select Weapon"] or "Melee")) end
- -- Combat / Attack
- local G_Combat = require(ReplicatedStorage.Modules.CombatUtil)
- local NetMod = require(ReplicatedStorage.Modules.Net)
- local RegisterAttack = ReplicatedStorage.Modules.Net:WaitForChild("RE/RegisterAttack")
- local RegisterHit = NetMod:RemoteEvent("RegisterHit", true)
- 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 }
- local function AttackAOE(radius, includePlayers)
- local found, seen = {}, {}
- local origins = { t.Character.HumanoidRootPart }
- -- Simplified hit detection for stability
- for _, mob in pairs(workspace.Enemies:GetChildren()) do
- if mob:FindFirstChild("HumanoidRootPart") and mob.Humanoid.Health > 0 then
- if (mob.HumanoidRootPart.Position - origins[1].Position).Magnitude <= radius + 15 then
- table.insert(found, { mob, mob.HumanoidRootPart })
- end
- end
- end
- return #found > 0 and found or nil
- end
- function attackMelee(radius)
- local tool = t.Character:FindFirstChildOfClass("Tool")
- if not tool then return end
- local hits = AttackAOE(radius, false)
- if not hits then return end
- local anims = G_Combat:GetMovesetAnimCache(t.Character.Humanoid)
- if anims then
- RegisterAttack:FireServer(0)
- RegisterHit:FireServer(table.remove(hits, 1)[2], hits)
- end
- end
- function AttackFunction(radius)
- if t.Character.Stun.Value ~= 0 then return end
- attackMelee(radius)
- end
- function ClickM1(mob, isBoat)
- if not mob or not mob:FindFirstChild("HumanoidRootPart") then return end
- if Settings["Select Weapon"] == "Blox Fruit" then
- local fruitTool = t.Character:FindFirstChild(NameWeapon("Blox Fruit"))
- if fruitTool and fruitTool:FindFirstChild("LeftClickRemote") then
- local lookDir = (mob.HumanoidRootPart.Position - t.Character.HumanoidRootPart.Position).Unit
- fruitTool.LeftClickRemote:FireServer(lookDir, math.random(1, 5))
- return
- end
- end
- AttackFunction(isBoat and 80 or 30)
- end
- -- Fast Attack
- local CombatFrameworkR = nil
- pcall(function()
- local cfMod = require(t.PlayerScripts:WaitForChild("CombatFramework"))
- local ups = getupvalues or (debug and debug.getupvalues)
- CombatFrameworkR = ups and ups(cfMod) and ups(cfMod)[2]
- end)
- task.spawn(function()
- while task.wait() do
- if getgenv().Usefastattack and CombatFrameworkR and CombatFrameworkR.activeController then
- pcall(function()
- local c = CombatFrameworkR.activeController
- c.hitboxMagnitude = 60
- c.timeToNextAttack = 0
- c.attacking = false
- if c.attack then c:attack() end
- end)
- end
- end
- end)
- -- Mob Detection
- function IsMobAlive(mob)
- return mob and mob.Parent and mob:FindFirstChild("HumanoidRootPart") and mob.Humanoid.Health > 0
- end
- function DetectMob(nameOrList)
- local best, bestDist = nil, math.huge
- for _, mob in pairs(workspace.Enemies:GetChildren()) do
- if (typeof(nameOrList) == "table" and table.find(nameOrList, mob.Name) or mob.Name == nameOrList) and IsMobAlive(mob) then
- local d = (mob.HumanoidRootPart.Position - t.Character.HumanoidRootPart.Position).Magnitude
- if d < bestDist then bestDist, best = d, mob end
- end
- end
- return best
- end
- function sizepart(mob)
- if t:DistanceFromCharacter(mob.HumanoidRootPart.Position) <= 50 then
- for _, part in pairs(mob:GetDescendants()) do if part:IsA("BasePart") and part.CanCollide then part.CanCollide = false end end
- end
- end
- -- Quest Logic (Simplified for stability)
- function TakeQuestLevel()
- -- Minimal quest taker
- local quests = {
- {lvl = 1, name = "Bandit", quest = "BanditQuest1", id = 1},
- {lvl = 10, name = "Monkey", quest = "JungleQuest", id = 1},
- {lvl = 15, name = "Gorilla", quest = "JungleQuest", id = 2},
- {lvl = 30, name = "Pirate", quest = "BuggyQuest1", id = 1},
- {lvl = 60, name = "Desert Bandit", quest = "DesertQuest", id = 1},
- {lvl = 90, name = "Snow Bandit", quest = "SnowQuest", id = 1},
- {lvl = 120, name = "Chief Petty Officer", quest = "MarineQuest2", id = 1},
- {lvl = 150, name = "Sky Bandit", quest = "SkyQuest", id = 1},
- }
- local currentLvl = t.Data.Level.Value
- local target = nil
- for _, q in ipairs(quests) do if currentLvl >= q.lvl then target = q end end
- if target then
- CommF:InvokeServer("StartQuest", target.quest, target.id)
- end
- end
- -- Main Farm Loop
- function FarmMethod()
- if not t.PlayerGui.Main.Quest.Visible then
- TakeQuestLevel()
- task.wait(1)
- return
- end
- local questTitle = t.PlayerGui.Main.Quest.Container.QuestTitle.Title.Text
- local mobName = ""
- -- Extract mob name from quest title (e.g. "Defeat 5 [Bandit]")
- for word in string.gmatch(questTitle, "%[([^%]]+)%]") do mobName = word end
- if mobName == "" then mobName = string.match(questTitle, "Defeat %d+ (.*)") end
- if not mobName or mobName == "" then return end
- local mob = DetectMob(mobName)
- if mob then
- repeat
- task.wait()
- if not IsMobAlive(mob) then break end
- sizepart(mob)
- UsedualFlock()
- if Settings["Select Weapon"] == "Blox Fruit" then
- toTarget(mob.HumanoidRootPart.CFrame * CFrame.new(-7, 20, 0))
- else
- toTarget(mob.HumanoidRootPart.CFrame * CFrame.new(7, 20, 0))
- end
- ClickM1(mob)
- until not IsMobAlive(mob) or not Settings["Start Farm"]
- else
- -- If no mob found, just wait a moment
- task.wait(1)
- end
- end
- task.spawn(function()
- while task.wait(0.1) do
- if Settings["Start Farm"] then
- pcall(FarmMethod)
- end
- end
- end)
- -- UI Setup
- local Window = Rayfield:CreateWindow({
- Name = "Gleavin Hub // Level Farm",
- LoadingTitle = "Gleavin Hub",
- LoadingSubtitle = "Level Farm",
- Theme = "Default",
- KeySystem = false,
- })
- local FarmTab = Window:CreateTab("Farm", 4483362458)
- FarmTab:CreateSection("Main Controls")
- 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 })
- 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 })
- FarmTab:CreateToggle({ Name = "Fast Attack", CurrentValue = getgenv().Usefastattack or false, Flag = "FastAttackFlag", Callback = function(v) getgenv().Usefastattack = v end })
- 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 })
- Rayfield:LoadConfiguration()
- Notify("Gleavin Hub", "Level Farm loaded successfully")
- end)
Advertisement
Add Comment
Please, Sign In to add comment