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.14376
- local ESPBillboard = nil
- local currentTarget = nil
- local lastPing = 0
- local pingUpdateInterval = 1 -- Update the prediction every 1 second for performance reasons
- local lastPingUpdateTime = tick()
- local smoothingFactor = 0.3 -- Controls how smooth the camera transition is
- -- 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
- -- Optimized Auto Prediction Function (updates less frequently)
- local function UpdatePrediction()
- local ping = Stats.Network.ServerStatsItem["Data Ping"]:GetValue() -- Get current ping
- -- Update only if ping changes significantly or at the update interval
- if math.abs(ping - lastPing) > 10 or (tick() - lastPingUpdateTime) >= pingUpdateInterval then
- lastPingUpdateTime = tick()
- lastPing = ping
- -- Set prediction value based on ping
- if ping >= 1000 then
- Prediction = 0.345
- elseif ping >= 900 then
- Prediction = 0.290724
- elseif ping >= 800 then
- Prediction = 0.254408
- elseif ping >= 700 then
- Prediction = 0.23398
- elseif ping >= 600 then
- Prediction = 0.215823
- elseif ping >= 500 then
- Prediction = 0.19284
- elseif ping >= 400 then
- Prediction = 0.18321
- elseif ping >= 360 then
- Prediction = 0.16537
- elseif ping >= 280 then
- Prediction = 0.16780
- elseif ping >= 270 then
- Prediction = 0.195566
- elseif ping >= 260 then
- Prediction = 0.175566
- elseif ping >= 250 then
- Prediction = 0.1651
- elseif ping >= 240 then
- Prediction = 0.16780
- elseif ping >= 230 then
- Prediction = 0.15692
- elseif ping >= 220 then
- Prediction = 0.165566
- elseif ping >= 210 then
- Prediction = 0.165566
- elseif ping >= 200 then
- Prediction = 0.16942
- elseif ping >= 190 then
- Prediction = 0.166547
- elseif ping >= 180 then
- Prediction = 0.19284
- elseif ping >= 170 then
- Prediction = 0.1923111
- elseif ping >= 160 then
- Prediction = 0.16
- elseif ping >= 150 then
- Prediction = 0.15
- elseif ping >= 140 then
- Prediction = 0.1223333
- elseif ping >= 130 then
- Prediction = 0.156692
- elseif ping >= 120 then
- Prediction = 0.14376
- elseif ping >= 110 then
- Prediction = 0.1455
- elseif ping >= 100 then
- Prediction = 0.130340
- elseif ping >= 90 then
- Prediction = 0.136
- elseif ping >= 80 then
- Prediction = 0.1347
- elseif ping >= 70 then
- Prediction = 0.119
- elseif ping >= 60 then
- Prediction = 0.12731
- elseif ping >= 50 then
- Prediction = 0.127668
- elseif ping >= 40 then
- Prediction = 0.125
- elseif ping >= 30 then
- Prediction = 0.11
- elseif ping >= 20 then
- Prediction = 0.12588
- elseif ping >= 10 then
- Prediction = 0.9
- else
- Prediction = 0.1 -- Default minimum prediction for very low ping
- end
- end
- end
- -- Function to smoothly 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 smoothly using Lerp
- local predictedPosition = currentTarget.Position + currentTarget.Velocity * Prediction
- local targetCFrame = CFrame.new(camera.CFrame.Position, predictedPosition)
- camera.CFrame = camera.CFrame:Lerp(targetCFrame, smoothingFactor) -- Lerp the camera smoothly to the target
- end
- end
- end)
- -- Continuously update prediction based on ping, but less frequently for performance
- RunService.Heartbeat:Connect(function()
- UpdatePrediction()
- 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 range
- end
- wait(0.05) -- Controls how fast the rainbow effect changes
- end
- end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement