benxogian

Untitled

Dec 27th, 2024
48
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.40 KB | None | 0 0
  1. local player = game.Players.LocalPlayer
  2. local camera = workspace.CurrentCamera
  3. local userInputService = game:GetService("UserInputService")
  4. local runService = game:GetService("RunService")
  5. local tweenService = game:GetService("TweenService")
  6. local gui = player:WaitForChild("PlayerGui")
  7.  
  8. -- Default values for smoothness and FOV
  9. local fovRadius = 100
  10. local aimAssistStrength = 0.005
  11. local predictionFactor = 0.1
  12. local hitboxSizeMultiplier = 1.2
  13.  
  14. local isLockedOn = false
  15. local currentTargetPlayer = nil
  16. local antiAimDetected = false
  17.  
  18. -- Function to find the closest player within the FOV
  19. local function getClosestPlayerInFOV()
  20. local screenCenter = Vector2.new(camera.ViewportSize.X / 2, camera.ViewportSize.Y / 2)
  21. local closestPlayer = nil
  22. local shortestDistance = fovRadius
  23.  
  24. for _, p in pairs(game.Players:GetPlayers()) do
  25. if p ~= player then
  26. local character = p.Character
  27. if character and character:FindFirstChild("Head") then
  28. local head = character.Head
  29. local headPos = camera:WorldToScreenPoint(head.Position)
  30.  
  31. local distance = (screenCenter - Vector2.new(headPos.X, headPos.Y)).Magnitude
  32. local directionToPlayer = (head.Position - camera.CFrame.Position).Unit
  33. local cameraForward = camera.CFrame.LookVector
  34. local dotProduct = directionToPlayer:Dot(cameraForward)
  35.  
  36. if distance <= fovRadius and dotProduct > 0.5 then
  37. if distance < shortestDistance then
  38. shortestDistance = distance
  39. closestPlayer = p
  40. end
  41. end
  42. end
  43. end
  44. end
  45.  
  46. return closestPlayer
  47. end
  48.  
  49. -- Improved movement prediction with more accuracy
  50. local function predictPlayerMovement(targetPlayer, deltaTime)
  51. local character = targetPlayer.Character
  52. if not character then return targetPlayer.Character.HumanoidRootPart.Position end
  53.  
  54. local humanoidRootPart = character:FindFirstChild("HumanoidRootPart")
  55. local humanoid = character:FindFirstChildOfClass("Humanoid")
  56.  
  57. if humanoidRootPart and humanoid then
  58. local velocity = humanoidRootPart.AssemblyLinearVelocity
  59. local predictedPosition = humanoidRootPart.Position + velocity * deltaTime * predictionFactor
  60.  
  61. -- Account for player acceleration to make the prediction more accurate
  62. if velocity.Magnitude > 20 then
  63. predictedPosition = predictedPosition + velocity.Unit * 1
  64. end
  65.  
  66. -- Adjust for player's jump velocity and more precise position calculation
  67. if humanoid:GetState() == Enum.HumanoidStateType.Physics or humanoid:GetState() == Enum.HumanoidStateType.Freefall then
  68. predictedPosition = predictedPosition - Vector3.new(0, 1, 0)
  69. end
  70.  
  71. return predictedPosition
  72. end
  73.  
  74. return targetPlayer.Character.HumanoidRootPart.Position
  75. end
  76.  
  77. -- Lock the camera to the target's predicted position
  78. local function lockOnToTarget(targetPlayer, deltaTime)
  79. if targetPlayer and targetPlayer.Character then
  80. local predictedPosition = predictPlayerMovement(targetPlayer, deltaTime)
  81.  
  82. local character = targetPlayer.Character
  83. local humanoidRootPart = character:FindFirstChild("HumanoidRootPart")
  84. local humanoid = character:FindFirstChildOfClass("Humanoid")
  85.  
  86. if humanoidRootPart and humanoid then
  87. local targetHeight = humanoidRootPart.Size.Y * hitboxSizeMultiplier
  88. local targetPosition = predictedPosition
  89.  
  90. -- Ensure that the aim is always above ground and avoid hitting the ground
  91. if predictedPosition.Y < character.HumanoidRootPart.Position.Y + targetHeight / 2 then
  92. predictedPosition = Vector3.new(predictedPosition.X, character.HumanoidRootPart.Position.Y + targetHeight / 2, predictedPosition.Z)
  93. end
  94.  
  95. -- Adjust to prevent shooting behind or too far from the target
  96. local aimSnapFactor = 0.2
  97. camera.CFrame = CFrame.new(camera.CFrame.Position:Lerp(predictedPosition, aimSnapFactor), predictedPosition)
  98.  
  99. -- Draw a purple dot on the target's torso to show prediction
  100. local torso = character:FindFirstChild("Torso") or character:FindFirstChild("UpperTorso")
  101. if torso then
  102. local dot = Instance.new("Part")
  103. dot.Shape = Enum.PartType.Ball
  104. dot.Size = Vector3.new(0.2, 0.2, 0.2) -- Small size for the dot
  105. dot.Position = torso.Position
  106. dot.Anchored = true
  107. dot.CanCollide = false
  108. dot.Color = Color3.fromRGB(255, 0, 255) -- Purple color
  109. dot.Parent = workspace
  110.  
  111. -- Fade out the dot after a short period
  112. game:GetService("Debris"):AddItem(dot, 1)
  113. end
  114. end
  115. end
  116. end
  117.  
  118. -- Detect when the triangle button (Y) is pressed on the controller
  119. userInputService.InputBegan:Connect(function(input, gameProcessed)
  120. if gameProcessed then return end
  121.  
  122. if input.UserInputType == Enum.UserInputType.Gamepad1 then
  123. if input.KeyCode == Enum.KeyCode.ButtonY then
  124. if isLockedOn then
  125. isLockedOn = false
  126. currentTargetPlayer = nil
  127. else
  128. local targetPlayer = getClosestPlayerInFOV()
  129. if targetPlayer then
  130. isLockedOn = true
  131. currentTargetPlayer = targetPlayer
  132. end
  133. end
  134. end
  135. end
  136. end)
  137.  
  138. -- Prevent connection drop by checking if gameProcessed is false and fixing lock-on state
  139. userInputService.InputChanged:Connect(function(input)
  140. if isLockedOn and currentTargetPlayer then
  141. -- Only lock camera when it's necessary
  142. if input.UserInputType == Enum.UserInputType.MouseMovement or input.UserInputType == Enum.UserInputType.Touch then
  143. local targetPlayer = currentTargetPlayer
  144. local headPos = camera:WorldToScreenPoint(targetPlayer.Character.Head.Position)
  145. camera.CFrame = CFrame.new(camera.CFrame.Position, targetPlayer.Character.HumanoidRootPart.Position)
  146. end
  147. end
  148. end)
  149.  
  150. -- Update the aim assist and smoothly transition to the closest player in FOV if locked
  151. runService.Heartbeat:Connect(function(deltaTime)
  152. if isLockedOn and currentTargetPlayer then
  153. lockOnToTarget(currentTargetPlayer, deltaTime)
  154. else
  155. if currentTargetPlayer then
  156. local newTargetPlayer = getClosestPlayerInFOV()
  157.  
  158. if newTargetPlayer ~= currentTargetPlayer then
  159. currentTargetPlayer = newTargetPlayer
  160. end
  161.  
  162. if currentTargetPlayer then
  163. lockOnToTarget(currentTargetPlayer, deltaTime)
  164. end
  165. end
  166. end
  167. end)
  168.  
  169. -- Create the "Cware" logo with rainbow and fancy font
  170. local function createCwareLogo()
  171. local screenGui = Instance.new("ScreenGui")
  172. screenGui.Parent = gui
  173.  
  174. local textLabel = Instance.new("TextLabel")
  175. textLabel.Parent = screenGui
  176. textLabel.Text = "Cware"
  177. textLabel.Font = Enum.Font.GothamBold
  178. textLabel.TextSize = 48
  179. textLabel.TextColor3 = Color3.fromRGB(255, 0, 0)
  180. textLabel.TextStrokeTransparency = 0.6
  181. textLabel.AnchorPoint = Vector2.new(0.5, 0.5)
  182. textLabel.Position = UDim2.new(0.5, 0, 0.5, 0)
  183. textLabel.BackgroundTransparency = 1
  184.  
  185. -- Add white outline to the text
  186. textLabel.TextStrokeTransparency = 0.5
  187. textLabel.TextStrokeColor3 = Color3.fromRGB(255, 255, 255) -- White stroke
  188.  
  189. local function updateRainbowColor()
  190. while textLabel.Parent do
  191. local time = tick()
  192. local color = Color3.fromHSV(time % 6 / 6, 1, 1)
  193. textLabel.TextColor3 = color
  194. wait(0.03)
  195. end
  196. end
  197.  
  198. local tweenInfoIn = TweenInfo.new(1, Enum.EasingStyle.Quad, Enum.EasingDirection.In)
  199. local tweenInfoOut = TweenInfo.new(1, Enum.EasingStyle.Quad, Enum.EasingDirection.Out, 0, false, 0)
  200. local fadeIn = tweenService:Create(textLabel, tweenInfoIn, {TextTransparency = 0})
  201. local fadeOut = tweenService:Create(textLabel, tweenInfoOut, {TextTransparency = 1})
  202.  
  203. fadeIn:Play()
  204. wait(2)
  205. fadeOut:Play()
  206.  
  207. updateRainbowColor()
  208.  
  209. wait(5)
  210. screenGui:Destroy()
  211. end
  212.  
  213. wait(3)
  214.  
  215. createCwareLogo()
Advertisement
Add Comment
Please, Sign In to add comment