Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local Players = game:GetService("Players")
- local RunService = game:GetService("RunService")
- local LocalPlayer = Players.LocalPlayer
- local Mouse = LocalPlayer:GetMouse()
- local CamlockState = false
- local Prediction = 0.16
- local Locked = true
- getgenv().Key = "c"
- function FindNearestEnemy()
- local ClosestDistance, ClosestPlayer = math.huge, nil
- local CenterPosition = Vector2.new(
- game:GetService("GuiService"):GetScreenResolution().X / 2,
- game:GetService("GuiService"):GetScreenResolution().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:GetService("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
- local enemy = nil
- RunService.Heartbeat:Connect(function()
- if CamlockState and enemy then
- local camera = workspace.CurrentCamera
- camera.CFrame = CFrame.new(camera.CFrame.p, enemy.Position + enemy.Velocity * Prediction)
- end
- end)
- Mouse.KeyDown:Connect(function(k)
- if k == getgenv().Key then
- Locked = not Locked
- if Locked then
- enemy = FindNearestEnemy()
- CamlockState = true
- else
- CamlockState = false
- enemy = nil
- end
- end
- end)
- -- GUI Elements
- local BladLock = Instance.new("ScreenGui")
- local Frame = Instance.new("Frame")
- local UICorner = Instance.new("UICorner")
- local Logo = Instance.new("ImageLabel")
- local TextButton = Instance.new("TextButton")
- local Notification = Instance.new("Frame")
- local NotificationText = Instance.new("TextLabel")
- local UICorner_Notification = Instance.new("UICorner")
- -- Properties
- BladLock.Name = "BladLock"
- BladLock.Parent = game.CoreGui
- Frame.Parent = BladLock
- Frame.BackgroundColor3 = Color3.fromRGB(20, 20, 20)
- Frame.BackgroundTransparency = 0.1
- Frame.Size = UDim2.new(0, 240, 0, 100)
- Frame.Position = UDim2.new(0.5, -120, 0.5, -50)
- Frame.AnchorPoint = Vector2.new(0.5, 0.5)
- Frame.Active = true
- Frame.Draggable = true
- UICorner.CornerRadius = UDim.new(0, 12)
- UICorner.Parent = Frame
- Logo.Name = "Logo"
- Logo.Parent = Frame
- Logo.BackgroundTransparency = 1
- Logo.Size = UDim2.new(0, 70, 0, 70)
- Logo.Position = UDim2.new(0.05, 0, 0.15, 0)
- Logo.Image = "rbxassetid://1025558188"
- TextButton.Parent = Frame
- TextButton.Size = UDim2.new(0, 140, 0, 40)
- TextButton.Position = UDim2.new(0.4, 0, 0.3, 0)
- TextButton.BackgroundColor3 = Color3.fromRGB(60, 60, 60)
- TextButton.Text = "Toggle CamLock"
- TextButton.Font = Enum.Font.SourceSansBold
- TextButton.TextScaled = true
- TextButton.TextColor3 = Color3.fromRGB(255, 255, 255)
- local ButtonCorner = Instance.new("UICorner")
- ButtonCorner.CornerRadius = UDim.new(0, 8)
- ButtonCorner.Parent = TextButton
- TextButton.MouseButton1Click:Connect(function()
- CamlockState = not CamlockState
- enemy = CamlockState and FindNearestEnemy() or nil
- TextButton.Text = CamlockState and "ON" or "OFF"
- end)
- -- Notification Badge
- Notification.Parent = BladLock
- Notification.BackgroundColor3 = Color3.fromRGB(35, 35, 35)
- Notification.Size = UDim2.new(0, 300, 0, 50)
- Notification.Position = UDim2.new(0.5, -150, 0.8, 0)
- Notification.AnchorPoint = Vector2.new(0.5, 0.5)
- Notification.BackgroundTransparency = 0.2
- UICorner_Notification.CornerRadius = UDim.new(0, 12)
- UICorner_Notification.Parent = Notification
- NotificationText.Parent = Notification
- NotificationText.Size = UDim2.new(1, 0, 1, 0)
- NotificationText.Font = Enum.Font.SourceSansBold
- NotificationText.TextScaled = true
- NotificationText.TextColor3 = Color3.fromRGB(255, 255, 255)
- NotificationText.Text = "Don't forget to subscribe @zcriptzplayzz!"
- NotificationText.BackgroundTransparency = 1
- -- Auto-hide notification
- task.spawn(function()
- wait(5)
- Notification:Destroy()
- end)
Advertisement
Add Comment
Please, Sign In to add comment