- --Game Link: https://www.roblox.com/games/1240123653/Zombie-Attack
- local Mobs = {
- workspace.enemies,
- workspace.BossFolder
- }
- local Players = game:GetService("Players")
- local Player = Players.LocalPlayer
- local Mouse = Player:GetMouse()
- local RunService = game:GetService("RunService")
- local TweenService = game:GetService("TweenService")
- local HitTI = TweenInfo.new(.4, Enum.EasingStyle.Linear, Enum.EasingDirection.InOut)
- local GunModule = game:GetService("ReplicatedStorage").GunData
- local KnifeInvoke = game:GetService("ReplicatedStorage").forhackers
- local UserInputService = game:GetService("UserInputService")
- -- Gun Mods
- for i, v in pairs(require(GunModule)) do
- v["Automatic"] = true
- v["Spread"] = {
- Min = 0,
- Max = 0,
- Inc = 0,
- Rec = 0
- }
- end
- local IsKnifeEquipped = function()
- if Player.Character:FindFirstChild("Basic Knife") then return true end
- return false
- end
- local GetClosestToCursor = function()
- local closestDistance = math.huge
- local closestEnemy = nil
- for i, folder in pairs(Mobs) do
- for _, enemy in pairs(folder:GetChildren()) do
- if not enemy:FindFirstChild("Head") then continue end
- if not enemy:FindFirstChildOfClass("Humanoid") then continue end
- if enemy.Humanoid.Health <= 0 then continue end
- local screenPos, visible = workspace.CurrentCamera:WorldToViewportPoint(enemy.Head.Position)
- if not visible then continue end
- local distance = (Vector2.new(Mouse.X, Mouse.Y) - Vector2.new(screenPos.X, screenPos.Y)).Magnitude
- if distance < closestDistance then
- closestEnemy = enemy
- closestDistance = distance
- end
- end
- end
- return closestEnemy
- end
- local ClosestEnemy = GetClosestToCursor()
- RunService.Stepped:Connect(function(time, deltaTime)
- ClosestEnemy = GetClosestToCursor()
- if UserInputService:IsMouseButtonPressed(Enum.UserInputType.MouseButton1) and IsKnifeEquipped() and ClosestEnemy then
- KnifeInvoke:InvokeServer("throw", "Basic Knife", ClosestEnemy.Head.CFrame)
- end
- end)
- local Highlight = function(ClosestEnemy)
- local hl = Instance.new("Highlight")
- hl.Adornee = ClosestEnemy
- hl.FillColor = Color3.fromRGB(255, 0, 0)
- hl.FillTransparency = .2
- hl.OutlineColor = Color3.fromRGB(200, 0, 0)
- hl.OutlineTransparency = .2
- hl.DepthMode = Enum.HighlightDepthMode.AlwaysOnTop
- hl.Parent = ClosestEnemy
- local t = TweenService:Create(hl, HitTI, {FillTransparency = 1, OutlineTransparency= .8})
- t.Completed:Connect(function()
- hl:Destroy()
- end)
- t:Play()
- end
- local old; old = hookmetamethod(game, "__index", function(this, index)
- if not checkcaller() and this == Mouse and index == "Hit" then
- if ClosestEnemy then
- task.spawn(Highlight, ClosestEnemy)
- return ClosestEnemy.Head.CFrame
- end
- end
- return old(this, index)
- end)