Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local Players = game:GetService("Players")
- local RunService = game:GetService("RunService")
- local UserInputService = game:GetService("UserInputService")
- local Stats = game:GetService("Stats")
- local LocalPlayer = Players.LocalPlayer
- local CamlockState = false
- local Prediction = 0.16289702
- local ESPBillboard = nil
- local currentTarget = nil
- -- Function to find the nearest enemy
- function FindNearestEnemy()
- local ClosestDistance, ClosestPlayer = math.huge, nil
- local CenterPosition = Vector2.new(game.Workspace.CurrentCamera.ViewportSize.X / 2, game.Workspace.CurrentCamera.ViewportSize.Y / 2)
- for _, Player in ipairs(Players:GetPlayers()) do
- if Player ~= LocalPlayer then
- local Character = Player.Character
- if Character and Character:FindFirstChild("HumanoidRootPart") and Character.Humanoid.Health > 0 then
- local Position, IsVisibleOnViewport = game.Workspace.CurrentCamera:WorldToViewportPoint(Character.HumanoidRootPart.Position)
- if IsVisibleOnViewport then
- local Distance = (CenterPosition - Vector2.new(Position.X, Position.Y)).Magnitude
- if Distance < ClosestDistance then
- ClosestPlayer = Character.HumanoidRootPart
- ClosestDistance = Distance
- end
- end
- end
- end
- end
- return ClosestPlayer
- end
- -- Auto Prediction Function (calculates based on ping)
- local function UpdatePrediction()
- local ping = Stats.Network.ServerStatsItem["Data Ping"]:GetValue() -- Get current ping
- if ping < 50 then
- Prediction = 0.1 -- Low ping, less prediction needed
- elseif ping < 100 then
- Prediction = 0.15 -- Mid ping
- elseif ping < 200 then
- Prediction = 0.2 -- High ping
- else
- Prediction = 0.25 -- Very high ping, larger prediction
- end
- end
- -- Function to aim the camera at the nearest enemy's HumanoidRootPart with auto prediction
- RunService.Heartbeat:Connect(function()
- if CamlockState == true then
- if currentTarget then
- local camera = workspace.CurrentCamera
- -- Predict the target's position and adjust the camera to look at it
- camera.CFrame = CFrame.new(camera.CFrame.Position, currentTarget.Position + currentTarget.Velocity * Prediction)
- end
- end
- end)
- -- Continuously update prediction based on ping
- RunService.Heartbeat:Connect(function()
- UpdatePrediction() -- Auto-update prediction every frame based on current ping
- end)
- -- Toggle the camlock when a target is locked
- UserInputService.InputBegan:Connect(function(input, gameProcessed)
- if gameProcessed then return end -- Ignore input if the game is using the input
- if input.KeyCode == Enum.KeyCode.Q then
- CamlockState = not CamlockState
- if CamlockState then
- currentTarget = FindNearestEnemy() -- Lock onto the nearest enemy
- else
- -- Disable Camlock
- currentTarget = nil
- end
- end
- end)
- -- PURIFY UI Setup (for controlling Camlock)
- local PURIFY = Instance.new("ScreenGui")
- local Frame = Instance.new("Frame")
- local UICorner = Instance.new("UICorner")
- local TextButton = Instance.new("TextButton")
- local UICorner_2 = Instance.new("UICorner")
- local UIStroke = Instance.new("UIStroke")
- -- Properties
- PURIFY.Name = "PURIFY"
- PURIFY.Parent = game.CoreGui
- PURIFY.ZIndexBehavior = Enum.ZIndexBehavior.Sibling
- Frame.Parent = PURIFY
- Frame.BackgroundColor3 = Color3.fromRGB(0, 0, 0) -- Pure black for a sleek look
- Frame.BorderColor3 = Color3.fromRGB(0, 0, 0)
- Frame.BorderSizePixel = 0
- Frame.Position = UDim2.new(0.133798108, 0, 0.20107238, 0)
- Frame.Size = UDim2.new(0, 202, 0, 70)
- Frame.Active = true
- Frame.Draggable = true
- UICorner.Parent = Frame
- TextButton.Parent = Frame
- TextButton.BackgroundColor3 = Color3.fromRGB(255, 255, 255)
- TextButton.BackgroundTransparency = 5.000
- TextButton.BorderColor3 = Color3.fromRGB(0, 0, 0)
- TextButton.BorderSizePixel = 0
- TextButton.Position = UDim2.new(0.0792079195, 0, 0.18571429, 0)
- TextButton.Size = UDim2.new(0, 170, 0, 44)
- TextButton.Font = Enum.Font.SourceSansSemibold
- TextButton.Text = "PURIFY OFF" -- Initial text when Camlock is off
- TextButton.TextColor3 = Color3.fromRGB(255, 255, 255)
- TextButton.TextScaled = true
- TextButton.TextSize = 11.000
- TextButton.TextWrapped = true
- -- Add UIStroke for sea-blue gradient effect
- UIStroke.Parent = Frame
- UIStroke.Thickness = 2
- UIStroke.ApplyStrokeMode = Enum.ApplyStrokeMode.Border
- UIStroke.Color = Color3.fromRGB(0, 255, 255) -- Initial sea blue color
- UICorner_2.Parent = TextButton
- -- Toggle the camlock and PURIFY mode on button click
- TextButton.MouseButton1Click:Connect(function()
- CamlockState = not CamlockState
- TextButton.Text = CamlockState and "PURIFY ON" or "PURIFY OFF" -- Toggle between ON and OFF
- if CamlockState then
- currentTarget = FindNearestEnemy()
- else
- currentTarget = nil
- end
- end)
- -- Create an ocean-blue rainbow effect for the button and the frame
- spawn(function()
- local hue = 180
- while true do
- -- Calculate the current color in the blue range (hue 180-240)
- local color = Color3.fromHSV(hue / 360, 0.8, 1)
- -- Apply the color to the text and stroke
- TextButton.TextColor3 = color
- UIStroke.Color = color
- -- Increment the hue for the rainbow effect
- hue = hue + 1
- if hue > 240 then
- hue = 180 -- Reset to start of ocean blue
- end
- wait(0.05) -- Controls how fast the rainbow effect changes
- end
- end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement