TEXT 92
Trenches Beta Script New By YarikPawPrison on 22nd January 2023 03:59:18 PM
  1. local library = loadstring(game:HttpGet('https://pastebin.com/raw/edJT9EGX', true))()
  2.  
  3. local plrs = game:service('Players')
  4. local local_plr = plrs.LocalPlayer
  5. local camera = workspace.CurrentCamera
  6. local mouse = local_plr:GetMouse()
  7. local WorldToViewportPoint = camera.WorldToViewportPoint
  8.  
  9. fov = {}
  10.  
  11. local main_window = library:CreateWindow('Main')
  12. main_window:AddToggle({text = 'Silent Aim', flag = 'silent_aim'})
  13. main_window:AddToggle({text = 'No Reload', flag = 'no_reload'})
  14.  
  15. function is_valid_plr(plr)
  16. return plr.ClassName == 'Player' and plr.Character and plr.Character:FindFirstChild('Humanoid') and plr.Character:FindFirstChild('HumanoidRootPart') and plr.Character.Humanoid.Health > 0 and plr.Name ~= local_plr.Name and local_plr.Character:FindFirstChild('TEAM') and plr.Character:FindFirstChild('TEAM') and plr.Character.TEAM.Value ~= local_plr.Character.TEAM.Value and true or false
  17. end
  18.  
  19. function get_target_plr()
  20.    local max_distance = math.huge
  21.    for i,v in next, plrs:GetPlayers() do
  22.        if local_plr.Character and is_valid_plr(v) then
  23.            local position, onscreen = WorldToViewportPoint(camera, v.Character.HumanoidRootPart.Position)
  24.            local magnitude = (Vector2.new(position.X, position.Y) - Vector2.new(mouse.X, mouse.Y)).magnitude
  25.            if magnitude < max_distance then
  26.                target = v
  27.                max_distance = magnitude
  28.            end
  29.        end
  30.    end
  31.    return target
  32. end
  33.  
  34. local v2 = require(game.ReplicatedStorage.Functions.GunRayCastModule)
  35.  
  36. function ray_cast(p1, p2, p3, p4)
  37. local v43, v44, v45 = v2.CastRay(local_plr, p1, p2, p3, p4, false);
  38. return v43, v44, v45
  39. end
  40.  
  41. function do_silent_aim(char)
  42. char.ChildAdded:connect(function(weapon)
  43. if weapon:FindFirstChild('LocalGunHeld') then
  44. local handlepart = weapon.HandlePart
  45. local x = getsenv(weapon.LocalGunHeld)
  46.  
  47. local old_fire = x.Fire
  48. local old_reload = x.Reload
  49.  
  50. x.Fire = newcclosure(function()
  51. local target = get_target_plr()
  52.  
  53. if library.flags['silent_aim'] and target and in_fov(target) then
  54. local plr_dir = CFrame.lookAt(camera.CFrame.p, target.Character.Head.CFrame.p)
  55.  
  56. local v46 = plr_dir * CFrame.Angles(0, 0, 0)
  57. local v48, v49, v50 = ray_cast(v46.Position, v46.lookVector, 5000, weapon)
  58. v48 = target.Character.Head
  59. game:service('ReplicatedStorage').ShootEvent:FireServer(v46, v46.lookVector, weapon, weapon.Variables, v48, v49)
  60.  
  61. local_plr.PlayerScripts.BulletVisualizerScript.Visualize:Fire(nil, handlepart, v49, 'Bullet', 'None', v48, nil, v46.lookVector, v50, 10)
  62. return
  63. else
  64. return old_fire()
  65. end
  66. end)
  67.  
  68. x.Reload = newcclosure(function()
  69. if library.flags['no_reload'] then
  70. weapon.Variables.Reloading.Value = true
  71. x.UpdateGUI()
  72. game:service('ReplicatedStorage').ReloadEvent:FireServer(weapon)
  73. weapon.Variables.CurrentMag.Value = weapon.Variables.AmmoPerMag.Value
  74. weapon.Variables.Reloading.Value = false
  75. x.UpdateGUI()
  76. return
  77. end
  78.  
  79. return old_reload()
  80. end)
  81.  
  82. x.ShakeCamera = function() return end
  83. end
  84. end)
  85. end
  86.  
  87. local_plr.CharacterAdded:connect(function(char) do_silent_aim(char) end)
  88.  
  89. local settings = library:CreateWindow('Settings')
  90.  
  91. settings:AddSlider({text = 'FOV', flag = 'fov_size', min = 1, max = 1000})
  92. settings:AddBind({text = 'Toggle UI', key = 'RightShift', callback = function() library:Close() end})
  93.  
  94. function update_fov()
  95. if not fov.fov then
  96. fov.fov = Drawing.new('Circle')
  97. fov.fov.Visible = false
  98. fov.fov.Thickness = 1
  99. fov.fov.NumSides = 360
  100. fov.fov.Filled = false
  101. end
  102.  
  103. if not fov.target then
  104. fov.target = Drawing.new('Text')
  105. fov.target.Visible = false
  106. fov.target.Text = ''
  107. fov.target.Size = 16
  108. fov.target.Center = false
  109. fov.target.Outline = true
  110. fov.target.Font = 0
  111. fov.target.Color = Color3.new(1, 1, 1)
  112. end
  113.  
  114. fov.fov.Visible = true
  115. fov.fov.Radius = library.flags['fov_size']
  116. fov.fov.Color = Color3.new(1, 1, 1)
  117. fov.fov.Transparency = 1
  118. fov.fov.Position = Vector2.new(mouse.X, mouse.Y + game:GetService('GuiService'):GetGuiInset().Y)
  119. end
  120.  
  121. function in_fov(target)
  122.    local min = math.huge
  123.    local fov_dist = math.huge
  124.  
  125.    local is_in_fov = false
  126.  
  127.    if is_valid_plr(target) then
  128.        local screenpoint, visible = WorldToViewportPoint(camera, target.Character.HumanoidRootPart.Position)
  129.        fov_dist = (Vector2.new(mouse.X, mouse.Y) - Vector2.new(screenpoint.X, screenpoint.Y)).magnitude
  130.        fov_dist = (fov_dist <= library.flags['fov_size']) and fov_dist or math.huge
  131.  
  132.        if fov_dist < min then
  133.            min = fov_dist
  134.            is_in_fov = true
  135.        end
  136.    end
  137.  
  138.    return is_in_fov
  139. end
  140.  
  141. game:service('RunService').RenderStepped:connect(function()
  142. update_fov()
  143. end)
  144. library:Init()

Texbin is for source code and general debugging text.

Login or Register to edit, delete and keep track of your pastes and more.

Raw Paste

Login or Register to edit or fork this paste. It's free.