get paid to paste

Murderers vs. Sheriffs Script | LASER GUN

local LASER_GUN_ENABLED = true
local GUN_DEBOUNCE_ENABLED = false
-- just dont touch anything below its shit but it works
local UserInputService = game:GetService("UserInputService")
local PlayersService = game:GetService("Players")

local LocalPlayer = PlayersService.LocalPlayer

local Hooked = {}
local isfunctionhooked = isfunctionhooked
if not isfunctionhooked then
    function isfunctionhooked(func)
        return Hooked[func] and true or false
    end
end

local function GetGunStuff(gun)
    local gunClient = gun:WaitForChild("GunClient", 3)
    if not gunClient then
        error("Failed to grab GunClient", 0)
    end

    local gunClientClosure = getscriptclosure(gunClient)
    if not gunClientClosure then
        error("Failed to grab GunClient's closure", 0)
    end

    local fireGuns = debug.getproto(gunClientClosure, 1, true)
    if not fireGuns or #fireGuns == 0 then
        error("Issues with grabbing fireGun func", 0)
    end

    local inputBeganHandlers = debug.getproto(gunClientClosure, 3, true)
    if not inputBeganHandlers or #inputBeganHandlers == 0 then
        error("Issues with grabbing InputBegan handler func", 0)
    end

    return fireGuns, inputBeganHandlers
end

local function HandleGun(gun)
    local fireGuns, inputBeganHandlers = GetGunStuff(gun)

    if not GUN_DEBOUNCE_ENABLED then
        for _, fireGun in ipairs(fireGuns) do
            pcall(debug.setconstant, fireGun, 5, 0)
        end
    end

    if LASER_GUN_ENABLED then
        for _, onInputBegan in ipairs(inputBeganHandlers) do
            if not isfunctionhooked(onInputBegan) then
              Hooked[onInputBegan] = true

              local originalFunc
              originalFunc = hookfunction(onInputBegan, function(input, gameProcessedEvent)
                  repeat
                        originalFunc(input, gameProcessedEvent)
                        task.wait()
                  until not UserInputService:IsMouseButtonPressed(Enum.UserInputType.MouseButton1)
              end)
            end
        end
    end
end

local HandledGuns = {}
local function WatchGun(gun)
    HandledGuns[gun] = true

    local ancestryConnection
    ancestryConnection = gun:GetPropertyChangedSignal("Parent"):Connect(function()
        if not gun.Parent then
            ancestryConnection:Disconnect()
            ancestryConnection = nil

            HandledGuns[gun] = nil
        end
    end)
end

if LASER_GUN_ENABLED then
    LocalPlayer.ChildAdded:Connect(function(child)
        if child.ClassName == "Backpack" then
            child.ChildAdded:Connect(function(child)
                if child.Name == "Gun" and not HandledGuns[child] then
                    task.wait(1)
                    WatchGun(child)
                    HandleGun(child)
                end
            end)
        end
    end)
end

local CurrentBackpack = LocalPlayer:FindFirstChildOfClass("Backpack")
if CurrentBackpack then
    local Gun = CurrentBackpack:FindFirstChild("Gun")
    if Gun then
        WatchGun(Gun)
        HandleGun(Gun)
    end
end

Pasted: Feb 26, 2023, 7:29:41 am
Views: 174