From venuslock, 3 Months ago, written in Plain Text.
Embed
  1. --Game Link: https://www.roblox.com/games/1240123653/Zombie-Attack
  2.  
  3. local Mobs = {
  4.     workspace.enemies,
  5.     workspace.BossFolder
  6. }
  7. local Players = game:GetService("Players")
  8. local Player = Players.LocalPlayer
  9. local Mouse = Player:GetMouse()
  10. local RunService = game:GetService("RunService")
  11. local TweenService = game:GetService("TweenService")
  12. local HitTI = TweenInfo.new(.4, Enum.EasingStyle.Linear, Enum.EasingDirection.InOut)
  13. local GunModule = game:GetService("ReplicatedStorage").GunData
  14. local KnifeInvoke = game:GetService("ReplicatedStorage").forhackers
  15. local UserInputService = game:GetService("UserInputService")
  16.  
  17. -- Gun Mods
  18. for i, v in pairs(require(GunModule)) do
  19.     v["Automatic"] = true
  20.     v["Spread"] = {
  21.         Min = 0,
  22.         Max = 0,
  23.         Inc = 0,
  24.         Rec = 0
  25.     }
  26. end
  27.  
  28. local IsKnifeEquipped = function()
  29.     if Player.Character:FindFirstChild("Basic Knife") then return true end
  30.     return false
  31. end
  32.  
  33. local GetClosestToCursor = function()
  34.    local closestDistance = math.huge
  35.    local closestEnemy = nil
  36.  
  37.    for i, folder in pairs(Mobs) do
  38.     for _, enemy in pairs(folder:GetChildren()) do
  39.         if not enemy:FindFirstChild("Head") then continue end
  40.         if not enemy:FindFirstChildOfClass("Humanoid") then continue end
  41.         if enemy.Humanoid.Health <= 0 then continue end
  42.         local screenPos, visible = workspace.CurrentCamera:WorldToViewportPoint(enemy.Head.Position)
  43.  
  44.         if not visible then continue end
  45.  
  46.         local distance = (Vector2.new(Mouse.X, Mouse.Y) - Vector2.new(screenPos.X, screenPos.Y)).Magnitude
  47.         if distance < closestDistance then
  48.             closestEnemy = enemy
  49.             closestDistance = distance
  50.         end
  51.     end
  52.    end
  53.  
  54.    return closestEnemy
  55. end
  56.  
  57. local ClosestEnemy = GetClosestToCursor()
  58. RunService.Stepped:Connect(function(time, deltaTime)
  59.    ClosestEnemy = GetClosestToCursor()
  60.    if UserInputService:IsMouseButtonPressed(Enum.UserInputType.MouseButton1) and IsKnifeEquipped() and ClosestEnemy then
  61.         KnifeInvoke:InvokeServer("throw", "Basic Knife", ClosestEnemy.Head.CFrame)
  62.     end
  63. end)
  64.  
  65. local Highlight = function(ClosestEnemy)
  66.    local hl = Instance.new("Highlight")
  67.    hl.Adornee = ClosestEnemy
  68.    hl.FillColor = Color3.fromRGB(255, 0, 0)
  69.    hl.FillTransparency = .2
  70.    hl.OutlineColor = Color3.fromRGB(200, 0, 0)
  71.    hl.OutlineTransparency = .2
  72.    hl.DepthMode = Enum.HighlightDepthMode.AlwaysOnTop
  73.    hl.Parent = ClosestEnemy
  74.    local t = TweenService:Create(hl, HitTI, {FillTransparency = 1, OutlineTransparency= .8})
  75.    t.Completed:Connect(function()
  76.        hl:Destroy()
  77.    end)
  78.    t:Play()
  79. end
  80.  
  81. local old; old = hookmetamethod(game, "__index", function(this, index)
  82.    if not checkcaller() and this == Mouse and index == "Hit" then
  83.        if ClosestEnemy then
  84.            task.spawn(Highlight, ClosestEnemy)
  85.            return ClosestEnemy.Head.CFrame
  86.        end
  87.    end
  88.  
  89.    return old(this, index)
  90. end)