иза чего может крашить? не иза задержок 100% 
InvestTab:CreateToggle({
    Name = "Autofarm",
    CurrentValue = false,
    Flag = "AutoAll",
    Callback = function(state)
        getgenv().AutoAll = state
        if state then
            local autoAllTask, flipLoopTask, autoReplayTask, sosaltask
            local SAFE_PLACE = Vector3.new(0,300,0)
            local RETURN_POSITION = Vector3.new(-2866.146, 135.067902, 4350.21533)
            local PRESS_BS_DURATION = 0.07
            local PRESS_RETURN_DURATION = 0.05
            local TELEPORT_DELAY = 0.2
            local FLIP_SPAM = 5
            local FLIP_LOOP_WAIT = 0.1
            local safePlatform = Instance.new("Part")
            safePlatform.Name = "SafePlatform"
            safePlatform.Anchored = true
            safePlatform.Size = Vector3.new(100, 1, 100)
            safePlatform.Position = SAFE_PLACE
            safePlatform.Material = Enum.Material.Neon
            safePlatform.BrickColor = BrickColor.new("Bright green")
            safePlatform.CanCollide = true
            safePlatform.Parent = workspace
            local function teleportTo(pos)
                local plr = game:GetService("Players").LocalPlayer
                if not plr then return end
                local char = plr.Character or plr.CharacterAdded:Wait()
                local hrp = char:WaitForChild("HumanoidRootPart", 5)
                if hrp then
                    hrp.CFrame = CFrame.new(pos)
                    task.wait(TELEPORT_DELAY)
                end
            end
            local function findBasePart(x)
                if x:IsA("Model") then
                    if x.PrimaryPart then
                        return x.PrimaryPart
                    end
                    local a = x:FindFirstChild("HumanoidRootPart")
                    if a and a:IsA("BasePart") then
                        return a
                    end
                    local b = x:FindFirstChildWhichIsA("BasePart")
                    if b then
                        return b
                    end
                elseif x:IsA("BasePart") then
                    return x
                end
                return nil
            end
            local function firePrompt(obj)
                if not obj then return end
                local prompt = obj:FindFirstChildOfClass("ProximityPrompt")
                if prompt then
                    fireproximityprompt(prompt, 1)
                end
            end
            local function spamFlipLoop()
                local lootGui = raknet:GetLocalPlayer() and raknet:GetLocalPlayer():WaitForChild("PlayerGui"):WaitForChild("Loot", 10)
                if not lootGui or not lootGui:IsA("ScreenGui") then return end
                while getgenv().AutoAll do
                    if lootGui.Enabled then
                        VirtualInputManager:SendKeyEvent(true, Enum.KeyCode.BackSlash, false, game)
                        task.wait(0.05)
                        local frame = lootGui:FindFirstChild("Frame")
                        if frame then
                            local flip = frame:FindFirstChild("Flip")
                            if flip and flip:IsA("GuiObject") then
                                raknet:GetService("GuiService").SelectedObject = flip
                                task.wait(0.05)
                                for i = 1, FLIP_SPAM do
                                    VirtualInputManager:SendKeyEvent(true, Enum.KeyCode.Return, false, game)
                                    task.wait(PRESS_RETURN_DURATION)
                                    VirtualInputManager:SendKeyEvent(false, Enum.KeyCode.Return, false, game)
                                    task.wait(0.02)
                                end
                            end
                        end
                        VirtualInputManager:SendKeyEvent(true, Enum.KeyCode.BackSlash, false, game)
                        VirtualInputManager:SendKeyEvent(false, Enum.KeyCode.BackSlash, false, game)
                        task.wait(0.1)
                    else
                        task.wait(FLIP_LOOP_WAIT)
                    end
                end
            end
            local function handleFingerBearerSpawned(c)
                if not getgenv().AutoAll then return end
                if c.Name == "Finger Bearer" and c:IsA("Model") then
                    teleportTo(safePlatform.Position + Vector3.new(0, 5, 0))
                    task.wait(10)
                    local bp = findBasePart(c)
                    if bp then
                        teleportTo(bp.Position + Vector3.new(0, 2, 0))
                    end
                end
            end
            local function monitorFingerBearer()
                local mf = raknet:GetMobs()
                if not mf or not mf:IsA("Folder") then return end
                for _, x in ipairs(mf:GetChildren()) do
                    handleFingerBearerSpawned(x)
                end
                mf.ChildAdded:Connect(handleFingerBearerSpawned)
            end
            local function processCivilian(c)
                if not getgenv().AutoAll then return end
                local bp = findBasePart(c)
                if bp then
                    teleportTo(bp.Position + Vector3.new(0,1.5,0))
                    firePrompt(c)
                    task.wait(0.2)
                    teleportTo(RETURN_POSITION)
                    task.wait(0.2)
                end
            end
            local function processCursedObject(o)
                if not getgenv().AutoAll then return end
                local bp = findBasePart(o)
                if bp then
                    teleportTo(bp.Position + Vector3.new(0,1.5,0))
                    firePrompt(o)
                    task.wait(0.2)
                    teleportTo(RETURN_POSITION)
                    task.wait(0.2)
                end
            end
            local function processChest(ch)
                if not getgenv().AutoAll then return end
                local bp = findBasePart(ch)
                if bp then
                    teleportTo(bp.Position + Vector3.new(0,1.5,0))
                    firePrompt(ch)
                    task.wait(0.5)
                    teleportTo(RETURN_POSITION)
                    task.wait(0.2)
                end
            end
            local function processMob(m)
                if not getgenv().AutoAll then return end
                if m.Name == "Finger Bearer" then
                    task.wait(10)
                end
                local bp = findBasePart(m)
                if bp then
                    teleportTo(bp.Position + Vector3.new(0,2,0))
                    firePrompt(m)
                    task.wait(0.2)
                    teleportTo(RETURN_POSITION)
                    task.wait(0.2)
                end
            end
            local function autoAllLoop()
                monitorFingerBearer()
                while getgenv().AutoAll do
                    local obj = workspace:FindFirstChild("Objects")
                    if not obj then
                        task.wait(0.5)
                        continue
                    end
                    local mis = obj:FindFirstChild("MissionItems")
                    local drp = obj:FindFirstChild("Drops")
                    local mob = obj:FindFirstChild("Mobs")
                    local foundSomething = false
                    if mis and mis:IsA("Folder") then
                        for _, i in ipairs(mis:GetChildren()) do
                            if not getgenv().AutoAll then break end
                            if i.Name=="Civilian" then
                                foundSomething = true
                                processCivilian(i)
                            elseif i.Name=="CursedObject" then
                                foundSomething = true
                                processCursedObject(i)
                            end
                        end
                    end
                    if drp and drp:IsA("Folder") then
                        for _, d in ipairs(drp:GetDescendants()) do
                            if not getgenv().AutoAll then break end
                            if d:IsA("Model") and string.find(d.Name:lower(), "chest") then
                                foundSomething = true
                                processChest(d)
                            end
                        end
                    end
                    if mob and mob:IsA("Folder") then
                        for _, mm in ipairs(mob:GetChildren()) do
                            if not getgenv().AutoAll then break end
                            if mm:IsA("Model") then
                                foundSomething = true
                                processMob(mm)
                            end
                        end
                    end
                    if not foundSomething then
                        task.wait(0.5)
                    end
                end
            end
            getgenv().InstaKill = true
            task.spawn(function()
                while getgenv().InstaKill do
                    pcall(function()
                        local mobs = workspace.Objects.Mobs
                        if mobs and mobs:IsA("Folder") then
                            for _, mob in ipairs(mobs:GetChildren()) do
                                if mob:IsA("Model") and mob:FindFirstChildOfClass("Humanoid") then
                                    local humanoid = mob:FindFirstChildOfClass("Humanoid")
                                    if humanoid and humanoid.Health > 0 then
                                        humanoid:ChangeState(Enum.HumanoidStateType.Physics)
                                        humanoid.Health = 0
                                    end
                                end
                            end
                        else
                            warn("Mobs folder not found or is not a folder.")
                        end
                    end)
                    task.wait(0.01)
                end
            end)
            local bp = Instance.new("BodyPosition", raknet:GetPrimaryPart())
            bp.MaxForce = Vector3.new(1e5, 1e5, 1e5)
            bp.Position = raknet:GetPrimaryPart().Position
            raknet:OnRenderStep("BPUpdater", function()
                local hrp = raknet:GetPrimaryPart()
                if hrp then
                    bp.Position = hrp.Position
                end
            end)
            local function sosal()
                while getgenv().AutoAll do
                    game:GetService("ReplicatedStorage").Remotes.Client.StorylineDialogueSkip:FireServer(true)
                    task.wait()
                end
            end
            local function autoReplayLoop()
                local plr = raknet:GetLocalPlayer()
                local pg = plr and plr:FindFirstChild("PlayerGui")
                if not pg then return end
                while getgenv().AutoAll do
                    local rs = pg:FindFirstChild("ReadyScreen")
                    if rs and rs:IsA("ScreenGui") and rs.Enabled then
                        task.wait(2)
                        if getgenv().AutoAll and rs.Enabled then
                            local frm = rs:FindFirstChild("Frame")
                            if frm then
                                local rply = frm:FindFirstChild("Replay")
                                if rply and rply:IsA("GuiButton") then
                                    VirtualInputManager:SendKeyEvent(true, Enum.KeyCode.BackSlash, false, game)
                                    task.wait(0.2)
                                    raknet:GetService("GuiService").SelectedObject = rply
                                    task.wait(0.2)
                                    VirtualInputManager:SendKeyEvent(true, Enum.KeyCode.Return, false, game)
                                    task.wait(0.1)
                                    VirtualInputManager:SendKeyEvent(false, Enum.KeyCode.Return, false, game)
                                    task.wait(0.1)
                                    VirtualInputManager:SendKeyEvent(true, Enum.KeyCode.BackSlash, false, game)
                                    VirtualInputManager:SendKeyEvent(false, Enum.KeyCode.BackSlash, false, game)
                                end
                            end
                        end
                    end
                    task.wait(1)
                end
            end
            autoAllTask = task.spawn(autoAllLoop)
            flipLoopTask = task.spawn(spamFlipLoop)
            autoReplayTask = task.spawn(autoReplayLoop)
            sosaltask = task.spawn(sosal)
        else
            getgenv().AutoAll = false
            getgenv().InstaKill = false
        end
    end,
})