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 LocalPlayer = Players.LocalPlayer
- local Mouse = game.Players.LocalPlayer:GetMouse()
- local CamlockState = false
- local Prediction = 0.2
- local XPrediction = 0.15
- local YPrediction = 0.15
- local enemy = nil
- local glowingPart = nil
- 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 function IsWallBetween(localPlayer, targetPart)
- local origin = localPlayer.Character.HumanoidRootPart.Position
- local direction = (targetPart.Position - origin).unit * (targetPart.Position - origin).magnitude
- local raycastParams = RaycastParams.new()
- raycastParams.FilterDescendantsInstances = {localPlayer.Character}
- raycastParams.FilterType = Enum.RaycastFilterType.Blacklist
- local ray = workspace:Raycast(origin, direction, raycastParams)
- return ray and ray.Instance and ray.Instance:IsDescendantOf(workspace) and not ray.Instance:IsDescendantOf(targetPart.Parent)
- end
- RunService.Heartbeat:Connect(function()
- if CamlockState and enemy then
- local camera = workspace.CurrentCamera
- local predictedPosition = enemy.Position + enemy.Velocity * Prediction + Vector3.new(enemy.Velocity.X * XPrediction, enemy.Velocity.Y * YPrediction, 0)
- camera.CFrame = CFrame.new(camera.CFrame.p, predictedPosition)
- if glowingPart then
- glowingPart.Enabled = true
- glowingPart.Parent = enemy
- glowingPart.Face = Enum.NormalId.Front
- end
- else
- if glowingPart then
- glowingPart:Destroy()
- end
- end
- end)
- local CamlockGUI = Instance.new("ScreenGui")
- local CamlockFrame = Instance.new("Frame")
- local CamlockButton = Instance.new("TextButton")
- local UICorner_1 = Instance.new("UICorner")
- local UIStroke_1 = Instance.new("UIStroke")
- CamlockGUI.Name = "CamlockGUI"
- CamlockGUI.Parent = game.CoreGui
- CamlockGUI.ZIndexBehavior = Enum.ZIndexBehavior.Sibling
- CamlockFrame.Parent = CamlockGUI
- CamlockFrame.BackgroundColor3 = Color3.fromRGB(48, 25, 52)
- CamlockFrame.BorderSizePixel = 0
- CamlockFrame.Position = UDim2.new(0.1, 0, 0.1, 0)
- CamlockFrame.Size = UDim2.new(0, 202, 0, 70)
- CamlockFrame.Active = true
- CamlockFrame.Draggable = true
- UICorner_1.CornerRadius = UDim.new(0, 12)
- UICorner_1.Parent = CamlockFrame
- CamlockButton.Parent = CamlockFrame
- CamlockButton.BackgroundColor3 = Color3.fromRGB(159, 43, 104)
- CamlockButton.BorderSizePixel = 0
- CamlockButton.Position = UDim2.new(0.079, 0, 0.185, 0)
- CamlockButton.Size = UDim2.new(0, 170, 0, 44)
- CamlockButton.Font = Enum.Font.SourceSansSemibold
- CamlockButton.Text = "Camlock OFF"
- CamlockButton.TextColor3 = Color3.fromRGB(255, 255, 255)
- CamlockButton.TextScaled = true
- CamlockButton.TextWrapped = true
- CamlockButton.MouseButton1Click:Connect(function()
- CamlockState = not CamlockState
- CamlockButton.Text = CamlockState and "Camlock ON" or "Camlock OFF"
- enemy = CamlockState and FindNearestEnemy() or nil
- if CamlockState then
- glowingPart = Instance.new("SurfaceLight")
- glowingPart.Color = Color3.fromRGB(128, 0, 255)
- glowingPart.Brightness = 10
- else
- if glowingPart then
- glowingPart:Destroy()
- end
- end
- end)
- UIStroke_1.Parent = CamlockFrame
- UIStroke_1.Thickness = 2
- UIStroke_1.ApplyStrokeMode = Enum.ApplyStrokeMode.Border
- UIStroke_1.Color = Color3.fromRGB(255, 255, 255)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement