hospital patient autofarm opsource
Key Required

hospital patient autofarm opsource

[GANGS REWORK] Ryujinmysopw2wwmysopw2ww 191 views 587 executesUpdated Aug 26, 2026
Unrated
00
Lua Script•462 lines (17976 chars)
local Players = game:GetService("Players")
local RunService = game:GetService("RunService")
local VirtualInputManager = game:GetService("VirtualInputManager")
local CoreGui = game:GetService("CoreGui")

local player = Players.LocalPlayer

local Config = {
    Enabled = false,
    Speed = 100
}

local screenGui = Instance.new("ScreenGui")
screenGui.Name = "PatientFarmerUI"
screenGui.ResetOnSpawn = false
pcall(function()
    screenGui.Parent = CoreGui
end)
if not screenGui.Parent then
    screenGui.Parent = player:WaitForChild("PlayerGui")
end

local mainFrame = Instance.new("Frame")
mainFrame.Name = "MainFrame"
mainFrame.Size = UDim2.new(0, 160, 0, 95)
mainFrame.Position = UDim2.new(0.02, 0, 0.4, 0)
mainFrame.BackgroundColor3 = Color3.fromRGB(30, 30, 30)
mainFrame.BorderSizePixel = 0
mainFrame.Active = true
mainFrame.Draggable = true
mainFrame.Parent = screenGui

local uiCorner = Instance.new("UICorner")
uiCorner.CornerRadius = UDim.new(0, 8)
uiCorner.Parent = mainFrame

local titleLabel = Instance.new("TextLabel")
titleLabel.Size = UDim2.new(1, 0, 0, 25)
titleLabel.BackgroundTransparency = 1
titleLabel.Text = "Farm UI"
titleLabel.TextColor3 = Color3.fromRGB(255, 255, 255)
titleLabel.TextSize = 11
titleLabel.Font = Enum.Font.GothamBold
titleLabel.Parent = mainFrame

local toggleButton = Instance.new("TextButton")
toggleButton.Size = UDim2.new(0.9, 0, 0, 25)
toggleButton.Position = UDim2.new(0.05, 0, 0.3, 0)
toggleButton.BackgroundColor3 = Color3.fromRGB(200, 50, 50)
toggleButton.Text = "Status: OFF"
toggleButton.TextColor3 = Color3.fromRGB(255, 255, 255)
toggleButton.TextSize = 11
toggleButton.Font = Enum.Font.GothamSemibold
toggleButton.Parent = mainFrame

local tCorner = Instance.new("UICorner")
tCorner.CornerRadius = UDim.new(0, 6)
tCorner.Parent = toggleButton

local speedBox = Instance.new("TextBox")
speedBox.Size = UDim2.new(0.9, 0, 0, 25)
speedBox.Position = UDim2.new(0.05, 0, 0.65, 0)
speedBox.BackgroundColor3 = Color3.fromRGB(45, 45, 45)
speedBox.Text = tostring(Config.Speed)
speedBox.PlaceholderText = "Speed"
speedBox.TextColor3 = Color3.fromRGB(255, 255, 255)
speedBox.TextSize = 11
speedBox.Font = Enum.Font.Gotham
speedBox.ClearTextOnFocus = false
speedBox.Parent = mainFrame

local sCorner = Instance.new("UICorner")
sCorner.CornerRadius = UDim.new(0, 6)
sCorner.Parent = speedBox

local shiftTaken = false
local savedMakimaCFrame = nil

speedBox.FocusLost:Connect(function()
    local val = tonumber(speedBox.Text)
    if val and val > 0 then
        Config.Speed = val
    else
        speedBox.Text = tostring(Config.Speed)
    end
end)

toggleButton.MouseButton1Click:Connect(function()
    Config.Enabled = not Config.Enabled
    if Config.Enabled then
        toggleButton.Text = "Status: ON"
        toggleButton.BackgroundColor3 = Color3.fromRGB(50, 200, 50)
        shiftTaken = false
    else
        toggleButton.Text = "Status: OFF"
        toggleButton.BackgroundColor3 = Color3.fromRGB(200, 50, 50)
        if player.Character then
            for _, part in ipairs(player.Character:GetDescendants()) do
                if part:IsA("BasePart") then
                    part.CanCollide = true
                end
            end
        end
    end
end)

local function getBalance()
    local success, cashObj = pcall(function()
        return player.PlayerGui.HUD.Bars.MainHUD.Cash
    end)
    
    if success and cashObj then
        local rawText = cashObj.Text or ""
        local cleanDigits = rawText:gsub("[^%d]", "")
        return tonumber(cleanDigits) or 0
    end
    return 0
end

local function triggerInteraction(targetNpc)
    if not targetNpc then return end
    local prompt = targetNpc:FindFirstChildWhichIsA("ProximityPrompt", true)
    if prompt then
        pcall(function()
            fireproximityprompt(prompt)
        end)
    else
        VirtualInputManager:SendKeyEvent(true, Enum.KeyCode.E, false, game)
        task.wait(0.1)
        VirtualInputManager:SendKeyEvent(false, Enum.KeyCode.E, false, game)
    end
end

local function forceClickDialogueOption(optionName)
    optionName = tostring(optionName or 1)
    local success, optionsFolder = pcall(function()
        return player.PlayerGui.HUD.Main.Dialogue.Options
    end)
    if not success or not optionsFolder then return false end
    
    local rawOption = optionsFolder:FindFirstChild(optionName)
    if not rawOption then return false end
    
    local clickable = rawOption:IsA("TextButton") or rawOption:IsA("ImageButton") 
        and rawOption 
        or rawOption:FindFirstChildWhichIsA("TextButton", true) 
        or rawOption:FindFirstChildWhichIsA("ImageButton", true) 
        or rawOption

    if firesignal then
        pcall(function()
            firesignal(clickable.MouseButton1Click)
            firesignal(clickable.MouseButton1Down)
            firesignal(clickable.Activated)
        end)
    end

    local pos = clickable.AbsolutePosition
    local size = clickable.AbsoluteSize
    local centerX = pos.X + (size.X / 2)
    local centerY = pos.Y + (size.Y / 2)

    VirtualInputManager:SendMouseButtonEvent(centerX, centerY, 0, true, game, 0)
    task.wait(0.02)
    VirtualInputManager:SendMouseButtonEvent(centerX, centerY, 0, false, game, 0)
    
    VirtualInputManager:SendMouseButtonEvent(centerX, centerY + 36, 0, true, game, 0)
    task.wait(0.02)
    VirtualInputManager:SendMouseButtonEvent(centerX, centerY + 36, 0, false, game, 0)

    return true
end

local function depositToATM()
    local success, amountBox = pcall(function()
        return player.PlayerGui.HUD.Tabs.ATM.AmountBox
    end)
    
    if not success or not amountBox then return false end

    local pos = amountBox.AbsolutePosition
    local size = amountBox.AbsoluteSize
    local centerX = pos.X + (size.X / 2)
    local centerY = pos.Y + (size.Y / 2)

    VirtualInputManager:SendMouseButtonEvent(centerX, centerY + 36, 0, true, game, 0)
    task.wait(0.05)
    VirtualInputManager:SendMouseButtonEvent(centerX, centerY + 36, 0, false, game, 0)
    task.wait(0.1)

    amountBox.Text = "1000000"
    pcall(function()
        if amountBox:IsA("TextBox") then
            amountBox:CaptureFocus()
            task.wait(0.05)
            amountBox.Text = "1000000"
            task.wait(0.05)
            amountBox:ReleaseFocus(true)
        end
    end)

    local atmTab = amountBox.Parent
    local depositBtn = atmTab:FindFirstChild("Deposit") 
        or atmTab:FindFirstChild("DepositButton")
        or atmTab:FindFirstChild("Submit")

    if not depositBtn then
        for _, child in ipairs(atmTab:GetDescendants()) do
            if child:IsA("TextButton") and string.find(child.Text:lower(), "dep") then
                depositBtn = child
                break
            end
        end
    end

    if depositBtn then
        task.wait(0.2)
        if firesignal then
            pcall(function()
                firesignal(depositBtn.MouseButton1Click)
                firesignal(depositBtn.MouseButton1Down)
                firesignal(depositBtn.Activated)
            end)
        end

        local dPos = depositBtn.AbsolutePosition
        local dSize = depositBtn.AbsoluteSize
        local dCenterX = dPos.X + (dSize.X / 2)
        local dCenterY = dPos.Y + (dSize.Y / 2)

        VirtualInputManager:SendMouseButtonEvent(dCenterX, dCenterY + 36, 0, true, game, 0)
        task.wait(0.05)
        VirtualInputManager:SendMouseButtonEvent(dCenterX, dCenterY + 36, 0, false, game, 0)
        return true
    end
    return false
end

local function getMakimaInstance()
    return workspace:FindFirstChild("Ignore") 
        and workspace.Ignore:FindFirstChild("NPCs") 
        and workspace.Ignore.NPCs:FindFirstChild("Important NPCs") 
        and workspace.Ignore.NPCs["Important NPCs"]:FindFirstChild("Makima")
end

local function strictFlyTo(targetPos)
    local char = player.Character
    if not char or not char:FindFirstChild("HumanoidRootPart") then return end
    local hrp = char.HumanoidRootPart

    local startPos = hrp.Position
    local distance = (targetPos - startPos).Magnitude
    if distance < 1 then return end

    local travelTime = distance / Config.Speed
    local startTime = tick()

    while Config.Enabled do
        local elapsed = tick() - startTime
        local alpha = math.clamp(elapsed / travelTime, 0, 1)
        
        local currentTargetPos = startPos:Lerp(targetPos, alpha)
        hrp.AssemblyLinearVelocity = Vector3.zero
        hrp.AssemblyAngularVelocity = Vector3.zero
        hrp.CFrame = CFrame.new(currentTargetPos)

        if alpha >= 1 then break end
        RunService.RenderStepped:Wait()
    end

    hrp.AssemblyLinearVelocity = Vector3.zero
    hrp.AssemblyAngularVelocity = Vector3.zero
end

task.spawn(function()
    local skippedPatients = {}

    RunService.Stepped:Connect(function()
        if Config.Enabled and player.Character then
            for _, part in ipairs(player.Character:GetDescendants()) do
                if part:IsA("BasePart") then
                    part.CanCollide = false
                    part.AssemblyLinearVelocity = Vector3.zero
                    part.AssemblyAngularVelocity = Vector3.zero
                end
            end
        end
    end)

    while true do
        task.wait(0.1)
        
        if Config.Enabled then
            local char = player.Character
            if char and char:FindFirstChild("HumanoidRootPart") then
                local hrp = char.HumanoidRootPart
                
                local makimaObj = getMakimaInstance()
                if makimaObj then
                    local mPart = makimaObj:IsA("Model") and (makimaObj.PrimaryPart or makimaObj:FindFirstChild("HumanoidRootPart") or makimaObj:FindFirstChildOfClass("BasePart")) or makimaObj
                    if mPart then
                        savedMakimaCFrame = mPart.CFrame
                    end
                end
                
                local currentMoney = getBalance()
                
                if currentMoney >= 1000000 then
                    local atmTarget = workspace:FindFirstChild("Interactables") 
                        and workspace.Interactables:FindFirstChild("ATMs") 
                        and workspace.Interactables.ATMs:GetChildren()[20]
                        
                    if atmTarget then
                        local atmPart = atmTarget:IsA("Model") and (atmTarget.PrimaryPart or atmTarget:FindFirstChildOfClass("BasePart")) or atmTarget
                        if atmPart and atmPart:IsA("BasePart") then
                            local targetPos = atmPart.Position
                            local flightPos = targetPos - Vector3.new(0, 3.5, 0)
                            
                            strictFlyTo(flightPos)
                            
                            if Config.Enabled then
                                local risePos = targetPos + Vector3.new(0, 1, 0)
                                hrp.CFrame = CFrame.new(risePos)
                                
                                task.wait(0.2)
                                triggerInteraction(atmTarget)
                                task.wait(1.0)
                                depositToATM()
                                task.wait(0.5)
                                
                                shiftTaken = false
                            end
                        end
                    end
                end

                if Config.Enabled and not shiftTaken and getBalance() < 1000000 then
                    local targetCFrame = savedMakimaCFrame
                    if makimaObj then
                        local mPart = makimaObj:IsA("Model") and (makimaObj.PrimaryPart or makimaObj:FindFirstChild("HumanoidRootPart") or makimaObj:FindFirstChildOfClass("BasePart")) or makimaObj
                        if mPart then targetCFrame = mPart.CFrame end
                    end
                    
                    if targetCFrame then
                        local targetPos = targetCFrame.Position
                        local flightPos = targetPos - Vector3.new(0, 3.5, 0)
                        
                        strictFlyTo(flightPos)
                        
                        if Config.Enabled then
                            local risePos = targetPos + Vector3.new(0, 1.5, 0)
                            hrp.CFrame = CFrame.new(risePos)
                            
                            local waitStart = tick()
                            while not makimaObj and (tick() - waitStart < 3) do
                                task.wait(0.2)
                                makimaObj = getMakimaInstance()
                            end
                            
                            task.wait(0.2)
                            triggerInteraction(makimaObj)
                            
                            local dStart = tick()
                            local jobSuccessfullyTaken = false
                            
                            while tick() - dStart < 4 and Config.Enabled do
                                hrp.CFrame = CFrame.new(risePos)
                                
                                if forceClickDialogueOption(1) then
                                    jobSuccessfullyTaken = true
                                    task.wait(0.3)
                                    break
                                else
                                    triggerInteraction(makimaObj)
                                end
                                task.wait(0.3)
                            end
                            
                            hrp.CFrame = CFrame.new(flightPos)
                            
                            if jobSuccessfullyTaken then
                                shiftTaken = true
                            else
                                task.wait(0.5)
                            end
                        end
                    end
                end
                
                if Config.Enabled and shiftTaken and getBalance() < 1000000 then
                    local success, npcsFolder = pcall(function()
                        return game:GetService("Workspace").Ignore.NPCs.Miscs
                    end)
                    
                    if success and npcsFolder then
                        local children = npcsFolder:GetChildren()
                        local validPatients = {}
                        
                        for _, child in ipairs(children) do
                            if child.Name ~= "Fuji Katou" and not skippedPatients[child] then
                                table.insert(validPatients, child)
                            end
                        end
                        
                        if #validPatients == 0 then
                            skippedPatients = {}
                            for _, child in ipairs(children) do
                                if child.Name ~= "Fuji Katou" then
                                    table.insert(validPatients, child)
                                end
                            end
                        end
                        
                        local targetPatient = validPatients[1]
                        
                        if targetPatient then
                            local patientPart = targetPatient:IsA("Model") and (targetPatient.PrimaryPart or targetPatient:FindFirstChild("HumanoidRootPart") or targetPatient:FindFirstChildOfClass("BasePart")) or targetPatient
                            
                            if patientPart and patientPart:IsA("BasePart") then
                                local targetPos = patientPart.Position
                                local flightPos = targetPos - Vector3.new(0, 3.5, 0)
                                
                                strictFlyTo(flightPos)
                                
                                if Config.Enabled then
                                    local risePos = targetPos - Vector3.new(0, 8, 0)
                                    hrp.CFrame = CFrame.new(risePos)
                                    
                                    task.wait(0.1)
                                    
                                    if Config.Enabled then
                                        triggerInteraction(targetPatient)
                                        
                                        local startTime = tick()
                                        local collected = false
                                        
                                        while Config.Enabled and targetPatient.Parent ~= nil and (tick() - startTime < 2) do
                                            hrp.CFrame = CFrame.new(risePos)
                                            
                                            if not targetPatient:IsDescendantOf(npcsFolder) then
                                                collected = true
                                                break
                                            end
                                            
                                            RunService.RenderStepped:Wait()
                                        end
                                        
                                        if not collected and targetPatient.Parent ~= nil then
                                            skippedPatients[targetPatient] = true
                                        end
                                        
                                        hrp.CFrame = CFrame.new(flightPos)
                                    end
                                end
                            end
                        end
                    end
                end
            end
        end
    end
end)

Features & Information

pretty simple and must be buggy , auto dep at 1m

Community Comments (0)

No comments yet for this script.

More Scripts for [GANGS REWORK] Ryujin