Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --[[
- EzAimbot apart of EzLibrary
- Developed by ToddDev
- Skid to your hearts content. That's what it's meant for!
- ]]--
- --// Container
- local EzAimbot = {}
- --// Internal
- EzAimbot.__Internals = {}
- EzAimbot.__Internals.MainLoop = nil
- EzAimbot.__Internals.Camera = workspace.CurrentCamera
- EzAimbot.__Internals.Viewport = EzAimbot.__Internals.Camera.ViewportSize
- EzAimbot.__Internals.Players = game:GetService("Players")
- EzAimbot.__Internals.LocalPlayer = EzAimbot.__Internals.Players.LocalPlayer
- EzAimbot.__Internals.Character = EzAimbot.__Internals.LocalPlayer.Character
- EzAimbot.__Internals.Head = EzAimbot.__Internals.Character.Head
- EzAimbot.__Internals.Mouse = EzAimbot.__Internals.LocalPlayer:GetMouse()
- EzAimbot.__Internals.FOV = nil
- EzAimbot.__Internals.RunService = game:GetService("RunService")
- EzAimbot.__Internals.InputService = game:GetService("UserInputService")
- EzAimbot.__Internals.MousePosition = function()
- return Vector2.new(EzAimbot.__Internals.Mouse.X,EzAimbot.__Internals.Mouse.Y)
- end
- EzAimbot.__Internals.ClosestPlayer = function(friendlyfire) -- Most of this stuff was ripped right out of my upcoming hub
- local MousePos = EzAimbot.__Internals.MousePosition()
- local Radius = EzAimbot.__Internals.FOV.Radius
- local Closest = math.huge
- local Target = nil
- local function HandleTeam(player)
- local Team = EzAimbot.__Internals.LocalPlayer.Team
- local Result = true
- if player.Team == Team and friendlyfire then
- Result = true
- elseif player.Team == Team and friendlyfire == false then
- Result = false
- else
- Result = true
- end
- return Result
- end
- for k,v in pairs(EzAimbot.__Internals.Players:GetPlayers()) do
- pcall(function()
- if HandleTeam(v) then
- if v.Character:FindFirstChild("Head") and v ~= EzAimbot.__Internals.LocalPlayer then
- local Point,OnScreen = EzAimbot.__Internals.Camera:WorldToScreenPoint(v.Character.Head.Position)
- if OnScreen and #EzAimbot.__Internals.Camera:GetPartsObscuringTarget({EzAimbot.__Internals.Head.Position,v.Character.Head.Position},{EzAimbot.__Internals.Character,v.Character}) == 0 then
- local Distance = (Vector2.new(Point.X,Point.Y) - EzAimbot.__Internals.MousePosition()).magnitude
- if Distance < math.min(Radius,Closest) then
- Closest = Distance
- Target = v
- end
- end
- end
- end
- end)
- end
- return Target
- end
- EzAimbot.__Internals.RefreshInternals = function()
- EzAimbot.__Internals.Camera = workspace.CurrentCamera
- EzAimbot.__Internals.LocalPlayer = EzAimbot.__Internals.Players.LocalPlayer
- EzAimbot.__Internals.Character = EzAimbot.__Internals.LocalPlayer.Character
- EzAimbot.__Internals.Head = EzAimbot.__Internals.Character.Head
- end
- --// Main functions
- EzAimbot.Disable = function()
- if EzAimbot.__Internals.MainLoop then
- EzAimbot.__Internals.MainLoop:Disconnect()
- EzAimbot.__Internals.MainLoop = nil
- end
- if EzAimbot.__Internals.FOV then
- EzAimbot.__Internals.FOV:Remove()
- end
- EzAimbot.__Internals.RefreshInternals()
- end
- EzAimbot.Enable = function(showfov,fovconfig,key,friendlyfire)
- assert(typeof(showfov)=="boolean","EzAimbot.Enable | Expected Boolean as argument #1")
- assert(typeof(fovconfig)=="table","EzAimbot.Enable | Expected Table as argument #2")
- assert(fovconfig["Size"],"EzAimbot.Enable | Expected Size in argument #2")
- assert(fovconfig["Sides"],"EzAimbot.Enable | Expected Sides in argument #2")
- assert(fovconfig["Color"],"EzAimbot.Enable | Expected Color in argument #2")
- assert(type(fovconfig["Size"])=="number","EzAimbot.Enable | Expected Size in argument #2")
- assert(type(fovconfig["Sides"])=="number","EzAimbot.Enable | Expected Sides in argument #2")
- assert(typeof(fovconfig["Color"])=="Color3","EzAimbot.Enable | Expected Color in argument #2")
- assert(type(key)=="string","EzAimbot.Enable | Expected String as argument #3")
- assert(type(friendlyfire)=="boolean","EzAimbot.Enable | Expected Boolean as argument #4")
- local Size = fovconfig["Size"]
- local Sides = fovconfig["Sides"]
- local Color = fovconfig["Color"]
- if showfov then
- EzAimbot.__Internals.FOV = Drawing.new("Circle")
- local FOV = EzAimbot.__Internals.FOV
- FOV.NumSides = Sides
- FOV.Position = EzAimbot.__Internals.MousePosition()
- FOV.Radius = Size
- FOV.Thickness = 2
- FOV.Radius = Size
- FOV.Color = Color
- FOV.Visible = true
- end
- EzAimbot.__Internals.MainLoop = EzAimbot.__Internals.RunService.RenderStepped:Connect(function()
- if EzAimbot.__Internals.FOV then
- EzAimbot.__Internals.FOV.Position = EzAimbot.__Internals.MousePosition()
- end
- if EzAimbot.__Internals.InputService:IsKeyDown(Mouse.[key]) then
- local ClosestPlayer = EzAimbot.__Internals.ClosestPlayer(friendlyfire)
- if ClosestPlayer then
- EzAimbot.__Internals.Camera.CFrame = CFrame.new(EzAimbot.__Internals.Camera.CFrame.p,ClosestPlayer.Character.Head.CFrame.p)
- end
- EzAimbot.__Internals.RefreshInternals()
- end
- end)
- end
- return EzAimbot
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement