Advertisement
Eproq012

You404

Oct 12th, 2024
19
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.43 KB | None | 0 0
  1. local Players = game:GetService("Players")
  2. local RunService = game:GetService("RunService")
  3. local LocalPlayer = Players.LocalPlayer
  4. local Mouse = game.Players.LocalPlayer:GetMouse()
  5. local CamlockState = false
  6. local Prediction = 0.2
  7. local XPrediction = 0.15
  8. local YPrediction = 0.15
  9. local enemy = nil
  10. local glowingPart = nil
  11.  
  12. function FindNearestEnemy()
  13. local ClosestDistance, ClosestPlayer = math.huge, nil
  14. local CenterPosition = Vector2.new(game:GetService("GuiService"):GetScreenResolution().X / 2, game:GetService("GuiService"):GetScreenResolution().Y / 2)
  15.  
  16. for _, Player in ipairs(Players:GetPlayers()) do
  17. if Player ~= LocalPlayer then
  18. local Character = Player.Character
  19. if Character and Character:FindFirstChild("HumanoidRootPart") and Character.Humanoid.Health > 0 then
  20. local Position, IsVisibleOnViewport = game:GetService("Workspace").CurrentCamera:WorldToViewportPoint(Character.HumanoidRootPart.Position)
  21. if IsVisibleOnViewport then
  22. local Distance = (CenterPosition - Vector2.new(Position.X, Position.Y)).Magnitude
  23. if Distance < ClosestDistance then
  24. ClosestPlayer = Character.HumanoidRootPart
  25. ClosestDistance = Distance
  26. end
  27. end
  28. end
  29. end
  30. end
  31.  
  32. return ClosestPlayer
  33. end
  34.  
  35. local function IsWallBetween(localPlayer, targetPart)
  36. local origin = localPlayer.Character.HumanoidRootPart.Position
  37. local direction = (targetPart.Position - origin).unit * (targetPart.Position - origin).magnitude
  38. local raycastParams = RaycastParams.new()
  39. raycastParams.FilterDescendantsInstances = {localPlayer.Character}
  40. raycastParams.FilterType = Enum.RaycastFilterType.Blacklist
  41. local ray = workspace:Raycast(origin, direction, raycastParams)
  42.  
  43. return ray and ray.Instance and ray.Instance:IsDescendantOf(workspace) and not ray.Instance:IsDescendantOf(targetPart.Parent)
  44. end
  45.  
  46. RunService.Heartbeat:Connect(function()
  47. if CamlockState and enemy then
  48. local camera = workspace.CurrentCamera
  49. local predictedPosition = enemy.Position + enemy.Velocity * Prediction + Vector3.new(enemy.Velocity.X * XPrediction, enemy.Velocity.Y * YPrediction, 0)
  50.  
  51. camera.CFrame = CFrame.new(camera.CFrame.p, predictedPosition)
  52.  
  53. if glowingPart then
  54. glowingPart.Enabled = true
  55. glowingPart.Parent = enemy
  56. glowingPart.Face = Enum.NormalId.Front
  57. end
  58. else
  59. if glowingPart then
  60. glowingPart:Destroy()
  61. end
  62. end
  63. end)
  64.  
  65. local CamlockGUI = Instance.new("ScreenGui")
  66. local CamlockFrame = Instance.new("Frame")
  67. local CamlockButton = Instance.new("TextButton")
  68. local UICorner_1 = Instance.new("UICorner")
  69. local UIStroke_1 = Instance.new("UIStroke")
  70.  
  71. CamlockGUI.Name = "CamlockGUI"
  72. CamlockGUI.Parent = game.CoreGui
  73. CamlockGUI.ZIndexBehavior = Enum.ZIndexBehavior.Sibling
  74.  
  75. CamlockFrame.Parent = CamlockGUI
  76. CamlockFrame.BackgroundColor3 = Color3.fromRGB(48, 25, 52)
  77. CamlockFrame.BorderSizePixel = 0
  78. CamlockFrame.Position = UDim2.new(0.1, 0, 0.1, 0)
  79. CamlockFrame.Size = UDim2.new(0, 202, 0, 70)
  80. CamlockFrame.Active = true
  81. CamlockFrame.Draggable = true
  82.  
  83. UICorner_1.CornerRadius = UDim.new(0, 12)
  84. UICorner_1.Parent = CamlockFrame
  85.  
  86. CamlockButton.Parent = CamlockFrame
  87. CamlockButton.BackgroundColor3 = Color3.fromRGB(159, 43, 104)
  88. CamlockButton.BorderSizePixel = 0
  89. CamlockButton.Position = UDim2.new(0.079, 0, 0.185, 0)
  90. CamlockButton.Size = UDim2.new(0, 170, 0, 44)
  91. CamlockButton.Font = Enum.Font.SourceSansSemibold
  92. CamlockButton.Text = "Camlock OFF"
  93. CamlockButton.TextColor3 = Color3.fromRGB(255, 255, 255)
  94. CamlockButton.TextScaled = true
  95. CamlockButton.TextWrapped = true
  96.  
  97. CamlockButton.MouseButton1Click:Connect(function()
  98. CamlockState = not CamlockState
  99. CamlockButton.Text = CamlockState and "Camlock ON" or "Camlock OFF"
  100. enemy = CamlockState and FindNearestEnemy() or nil
  101.  
  102. if CamlockState then
  103. glowingPart = Instance.new("SurfaceLight")
  104. glowingPart.Color = Color3.fromRGB(128, 0, 255)
  105. glowingPart.Brightness = 10
  106. else
  107. if glowingPart then
  108. glowingPart:Destroy()
  109. end
  110. end
  111. end)
  112.  
  113. UIStroke_1.Parent = CamlockFrame
  114. UIStroke_1.Thickness = 2
  115. UIStroke_1.ApplyStrokeMode = Enum.ApplyStrokeMode.Border
  116. UIStroke_1.Color = Color3.fromRGB(255, 255, 255)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement