Advertisement
Guest User

Claude Target Lock

a guest
Mar 12th, 2025
25
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.33 KB | None | 0 0
  1. -- Target Lock Script for Roblox
  2. -- Created by Claude
  3.  
  4. local Players = game:GetService("Players")
  5. local RunService = game:GetService("RunService")
  6. local UserInputService = game:GetService("UserInputService")
  7. local LocalPlayer = Players.LocalPlayer
  8. local Camera = workspace.CurrentCamera
  9. local Mouse = LocalPlayer:GetMouse()
  10.  
  11. -- Target Lock Configuration
  12. local Config = {
  13. Enabled = false,
  14. Key = Enum.KeyCode.Q,
  15. FOV = {
  16. Size = 120,
  17. Transparency = 0.7,
  18. Thickness = 1,
  19. Filled = false,
  20. Color = Color3.fromRGB(255, 255, 255)
  21. },
  22. HitPart = "HumanoidRootPart", -- Default part to target
  23. AirShotHitPart = "LowerTorso", -- Part to target when player is in air
  24. Prediction = {
  25. X = 0.06,
  26. Y = 0.3
  27. },
  28. JumpOffset = 0.02, -- Vertical offset when target jumps
  29. Hitbox = {
  30. Size = 25,
  31. Transparency = 0.07,
  32. Color = Color3.fromRGB(255, 0, 0)
  33. }
  34. }
  35.  
  36. -- Variables
  37. local Target = nil
  38. local FOVCircle = Drawing.new("Circle")
  39. local HitboxPart = nil
  40.  
  41. -- Initialize FOV Circle
  42. FOVCircle.Visible = false
  43. FOVCircle.Radius = Config.FOV.Size
  44. FOVCircle.Transparency = Config.FOV.Transparency
  45. FOVCircle.Thickness = Config.FOV.Thickness
  46. FOVCircle.Filled = Config.FOV.Filled
  47. FOVCircle.Color = Config.FOV.Color
  48. FOVCircle.Position = Vector2.new(Camera.ViewportSize.X / 2, Camera.ViewportSize.Y / 2)
  49.  
  50. -- Function to check if a player is valid for targeting
  51. local function IsValidTarget(player)
  52. if player == LocalPlayer then return false end
  53. if not player.Character then return false end
  54. if not player.Character:FindFirstChild("Humanoid") then return false end
  55. if player.Character.Humanoid.Health <= 0 then return false end
  56.  
  57. -- Check if player is within FOV
  58. local screenPos, onScreen = Camera:WorldToScreenPoint(player.Character.HumanoidRootPart.Position)
  59. if not onScreen then return false end
  60.  
  61. local distance = (Vector2.new(screenPos.X, screenPos.Y) - FOVCircle.Position).Magnitude
  62. if distance > FOVCircle.Radius then return false end
  63.  
  64. -- Check for line of sight
  65. local rayParams = RaycastParams.new()
  66. rayParams.FilterDescendantsInstances = {LocalPlayer.Character}
  67. rayParams.FilterType = Enum.RaycastFilterType.Blacklist
  68.  
  69. local direction = (player.Character.HumanoidRootPart.Position - Camera.CFrame.Position).Unit
  70. local rayResult = workspace:Raycast(Camera.CFrame.Position, direction * 1000, rayParams)
  71.  
  72. if rayResult and rayResult.Instance and rayResult.Instance:IsDescendantOf(player.Character) then
  73. return true
  74. end
  75.  
  76. return false
  77. end
  78.  
  79. -- Function to get the closest player within FOV
  80. local function GetClosestPlayerInFOV()
  81. local closestPlayer = nil
  82. local shortestDistance = math.huge
  83.  
  84. for _, player in pairs(Players:GetPlayers()) do
  85. if IsValidTarget(player) then
  86. local screenPos = Camera:WorldToScreenPoint(player.Character.HumanoidRootPart.Position)
  87. local distance = (Vector2.new(screenPos.X, screenPos.Y) - FOVCircle.Position).Magnitude
  88.  
  89. if distance < shortestDistance then
  90. closestPlayer = player
  91. shortestDistance = distance
  92. end
  93. end
  94. end
  95.  
  96. return closestPlayer
  97. end
  98.  
  99. -- Function to create or update the hitbox
  100. local function UpdateHitbox()
  101. if not HitboxPart then
  102. HitboxPart = Instance.new("Part")
  103. HitboxPart.Name = "TargetHitbox"
  104. HitboxPart.Anchored = true
  105. HitboxPart.CanCollide = false
  106. HitboxPart.Material = Enum.Material.Neon
  107. HitboxPart.Shape = Enum.PartType.Ball
  108. HitboxPart.Parent = workspace
  109. end
  110.  
  111. if Target and Target.Character then
  112. HitboxPart.Size = Vector3.new(Config.Hitbox.Size, Config.Hitbox.Size, Config.Hitbox.Size)
  113. HitboxPart.Transparency = Config.Hitbox.Transparency
  114. HitboxPart.Color = Config.Hitbox.Color
  115. HitboxPart.Visible = true
  116. else
  117. HitboxPart.Visible = false
  118. end
  119. end
  120.  
  121. -- Function to get the target part based on if the player is in air
  122. local function GetTargetPart()
  123. if not Target or not Target.Character then return nil end
  124.  
  125. local humanoid = Target.Character:FindFirstChild("Humanoid")
  126. if humanoid and humanoid:GetState() == Enum.HumanoidStateType.Jumping or
  127. humanoid:GetState() == Enum.HumanoidStateType.Freefall then
  128. return Target.Character:FindFirstChild(Config.AirShotHitPart)
  129. end
  130.  
  131. return Target.Character:FindFirstChild(Config.HitPart)
  132. end
  133.  
  134. -- Toggle target lock
  135. UserInputService.InputBegan:Connect(function(input, gameProcessed)
  136. if gameProcessed then return end
  137.  
  138. if input.KeyCode == Config.Key then
  139. Config.Enabled = not Config.Enabled
  140. FOVCircle.Visible = Config.Enabled
  141.  
  142. if Config.Enabled then
  143. Target = GetClosestPlayerInFOV()
  144. UpdateHitbox()
  145. else
  146. Target = nil
  147. if HitboxPart then
  148. HitboxPart.Visible = false
  149. end
  150. end
  151. end
  152. end)
  153.  
  154. -- Main target lock loop
  155. RunService.RenderStepped:Connect(function()
  156. -- Update FOV circle position
  157. FOVCircle.Position = Vector2.new(Camera.ViewportSize.X / 2, Camera.ViewportSize.Y / 2)
  158.  
  159. if Config.Enabled and Target then
  160. -- Check if target is still valid
  161. if not IsValidTarget(Target) then
  162. Target = GetClosestPlayerInFOV()
  163. end
  164.  
  165. if Target then
  166. -- Get target part
  167. local targetPart = GetTargetPart()
  168. if not targetPart then return end
  169.  
  170. -- Apply prediction and jump offset
  171. local targetPosition = targetPart.Position
  172. local velocity = targetPart.Velocity
  173.  
  174. -- Apply prediction
  175. local predictedPosition = targetPosition + (velocity * Vector3.new(Config.Prediction.X, 0, Config.Prediction.Y))
  176.  
  177. -- Apply jump offset if needed
  178. local humanoid = Target.Character:FindFirstChild("Humanoid")
  179. if humanoid and (humanoid:GetState() == Enum.HumanoidStateType.Jumping or
  180. humanoid:GetState() == Enum.HumanoidStateType.Freefall) then
  181. predictedPosition = predictedPosition + Vector3.new(0, Config.JumpOffset, 0)
  182. end
  183.  
  184. -- Update camera to look at target
  185. Camera.CFrame = CFrame.lookAt(Camera.CFrame.Position, predictedPosition)
  186.  
  187. -- Update hitbox position
  188. if HitboxPart then
  189. HitboxPart.Position = targetPosition
  190. end
  191. end
  192. end
  193. end)
  194.  
  195. -- GUI elements for settings (optional)
  196. local function CreateSettingsGUI()
  197. -- Create basic settings GUI to adjust all parameters
  198. -- This is left as an extension point
  199. end
  200.  
  201. -- Update hitbox when target changes
  202. RunService.Heartbeat:Connect(function()
  203. if Config.Enabled and Target then
  204. UpdateHitbox()
  205. end
  206. end)
  207.  
  208. -- Cleanup on script unload
  209. game:GetService("CoreGui").ChildRemoved:Connect(function(child)
  210. if child.Name == script.Name then
  211. FOVCircle:Remove()
  212. if HitboxPart then
  213. HitboxPart:Destroy()
  214. end
  215. end
  216. end)
  217.  
  218. print("Target Lock script loaded! Press Q to toggle.")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement