Roblox Script Mano County Roleplay Kill All

if not game.Loaded then
    game.Loaded:Wait()
    wait(3)
end

local Players = game:GetService("Players")
local RunService = game:GetService("RunService")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local LocalPlayer = Players.LocalPlayer

local MoneyDataFolder = ReplicatedStorage:WaitForChild("MoneyData")
local LocalPlayerCashValue = MoneyDataFolder:WaitForChild(LocalPlayer.Name).Cash
local LocalPlayerBankValue = MoneyDataFolder:WaitForChild(LocalPlayer.Name).BankAccount
local ATMAction = ReplicatedStorage:WaitForChild("ATMAction")

local PlayerWhitelist = {}

local function IsPlayerWhitelisted(player)
    for _,v in pairs(PlayerWhitelist) do
        if v == player.Name then
            return true 
        end
    end
    return false
end

local function GetGunObject()
    if LocalPlayer.Backpack:FindFirstChild("AK47(LEGAL)") then
        return LocalPlayer.Backpack["AK47(LEGAL)"]
    else
        local LocalCharacter = LocalPlayer.Character or LocalPlayer.CharacterAdded:Wait()
        if LocalCharacter:FindFirstChild("AK47(LEGAL)") then
            return LocalCharacter:FindFirstChild("AK47(LEGAL)")
        end
    end
    return nil
end

local function GetGunRemote()
    local GunModel = GetGunObject()
    if GunModel ~= nil then
        return GunModel:FindFirstChild("RemoteEvent") 
    end
end

local function EquipGun()
    local GunModel = GetGunObject()
    if GunModel ~= nil then
        local LocalCharacter = LocalPlayer.Character or LocalPlayer.CharacterAdded:Wait()
        LocalCharacter.Humanoid:EquipTool(GunModel)
    end
end

local function UnEquipGun()
    local GunModel = GetGunObject()
    if GunModel ~= nil then
        local LocalCharacter = LocalPlayer.Character or LocalPlayer.CharacterAdded:Wait()
        LocalCharacter.Humanoid:UnequipTools()
    end
end

local function FireAtObject(part)
    local GunRemote = GetGunRemote()
    local args = {
        [1] = "Fire",
        [2] = part.Position,
        [3] = part,
        [4] = "editbynsxfa",
        [5] = part.Position,
        [6] = Vector3.new(0,1,0),
        [7] = "noob"
    }
    GunRemote:FireServer(unpack(args))
end

local function GetRemainingAmmo()
    local GunModel = GetGunObject()
    if GunModel ~= nil then
        return GunModel:WaitForChild("GunControl").AmmoSettings.MagAmmo.Value 
    end
end

local function ReloadGun()
    local GunRemote = GetGunRemote()
    if GunRemote ~= nil then
        local args = {
            [1] = "Reload"
        }
        GunRemote:FireServer(unpack(args))
    end
end

local function KillPlayer(player)
    pcall(function()
        local TargetPlayerCharacter = player.Character
        if TargetPlayerCharacter ~= nil then
            local TargetPlayerHumanoid = TargetPlayerCharacter:FindFirstChild("Humanoid")
            if TargetPlayerHumanoid ~= nil then
                local attempts = 0
                while RunService.Heartbeat:Wait() do
                    if TargetPlayerHumanoid.Health <= 0 or TargetPlayerHumanoid.Health >= 150 or TargetPlayerCharacter:FindFirstChild("ForceField") or attempts >= 34 or IsPlayerWhitelisted(player) then
                        break 
                    end
                    FireAtObject(TargetPlayerCharacter.Head)
                    attempts += 1
                    if GetRemainingAmmo() <= 0 then
                        ReloadGun() 
                    end
                    wait(0.05)
                end
            end
        end
    end)
end

if not GetGunObject() ~= nil then
    if LocalPlayerCashValue.Value >= 2500 then
        local args = {
            [1] = "AK47(LEGAL)",
            [2] = 2500,
            [3] = "Cash"
        }
        
        workspace.DealersScript.BuyItem:InvokeServer(unpack(args))
    else
        if LocalPlayerCashValue.Value + LocalPlayerBankValue.Value >= 2500 then
            ATMAction:FireServer(
                "Withdraw",
                2500 - LocalPlayerCashValue.Value
            )
            wait(0.8)
            local args = {
                [1] = "AK47(LEGAL)",
                [2] = 2500,
                [3] = "Cash"
            }
            
            workspace.DealersScript.BuyItem:InvokeServer(unpack(args))
        end
    end
end

if GetGunObject() ~= nil then
    
    EquipGun()
    wait(1.5)
    UnEquipGun()
    
    
    while wait() do
        for _,v in pairs(Players:GetChildren()) do
            if v ~= LocalPlayer then
                KillPlayer(v) 
            end
        end
    end
end