Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local player = game.Players.LocalPlayer
- local camera = workspace.CurrentCamera
- local userInputService = game:GetService("UserInputService")
- local runService = game:GetService("RunService")
- local tweenService = game:GetService("TweenService")
- local gui = player:WaitForChild("PlayerGui")
- -- Default values for smoothness and FOV
- local fovRadius = 100
- local aimAssistStrength = 0.005
- local predictionFactor = 0.1
- local hitboxSizeMultiplier = 1.2
- local isLockedOn = false
- local currentTargetPlayer = nil
- local antiAimDetected = false
- -- Function to find the closest player within the FOV
- local function getClosestPlayerInFOV()
- local screenCenter = Vector2.new(camera.ViewportSize.X / 2, camera.ViewportSize.Y / 2)
- local closestPlayer = nil
- local shortestDistance = fovRadius
- for _, p in pairs(game.Players:GetPlayers()) do
- if p ~= player then
- local character = p.Character
- if character and character:FindFirstChild("Head") then
- local head = character.Head
- local headPos = camera:WorldToScreenPoint(head.Position)
- local distance = (screenCenter - Vector2.new(headPos.X, headPos.Y)).Magnitude
- local directionToPlayer = (head.Position - camera.CFrame.Position).Unit
- local cameraForward = camera.CFrame.LookVector
- local dotProduct = directionToPlayer:Dot(cameraForward)
- if distance <= fovRadius and dotProduct > 0.5 then
- if distance < shortestDistance then
- shortestDistance = distance
- closestPlayer = p
- end
- end
- end
- end
- end
- return closestPlayer
- end
- -- Improved movement prediction with more accuracy
- local function predictPlayerMovement(targetPlayer, deltaTime)
- local character = targetPlayer.Character
- if not character then return targetPlayer.Character.HumanoidRootPart.Position end
- local humanoidRootPart = character:FindFirstChild("HumanoidRootPart")
- local humanoid = character:FindFirstChildOfClass("Humanoid")
- if humanoidRootPart and humanoid then
- local velocity = humanoidRootPart.AssemblyLinearVelocity
- local predictedPosition = humanoidRootPart.Position + velocity * deltaTime * predictionFactor
- -- Account for player acceleration to make the prediction more accurate
- if velocity.Magnitude > 20 then
- predictedPosition = predictedPosition + velocity.Unit * 1
- end
- -- Adjust for player's jump velocity and more precise position calculation
- if humanoid:GetState() == Enum.HumanoidStateType.Physics or humanoid:GetState() == Enum.HumanoidStateType.Freefall then
- predictedPosition = predictedPosition - Vector3.new(0, 1, 0)
- end
- return predictedPosition
- end
- return targetPlayer.Character.HumanoidRootPart.Position
- end
- -- Lock the camera to the target's predicted position
- local function lockOnToTarget(targetPlayer, deltaTime)
- if targetPlayer and targetPlayer.Character then
- local predictedPosition = predictPlayerMovement(targetPlayer, deltaTime)
- local character = targetPlayer.Character
- local humanoidRootPart = character:FindFirstChild("HumanoidRootPart")
- local humanoid = character:FindFirstChildOfClass("Humanoid")
- if humanoidRootPart and humanoid then
- local targetHeight = humanoidRootPart.Size.Y * hitboxSizeMultiplier
- local targetPosition = predictedPosition
- -- Ensure that the aim is always above ground and avoid hitting the ground
- if predictedPosition.Y < character.HumanoidRootPart.Position.Y + targetHeight / 2 then
- predictedPosition = Vector3.new(predictedPosition.X, character.HumanoidRootPart.Position.Y + targetHeight / 2, predictedPosition.Z)
- end
- -- Adjust to prevent shooting behind or too far from the target
- local aimSnapFactor = 0.2
- camera.CFrame = CFrame.new(camera.CFrame.Position:Lerp(predictedPosition, aimSnapFactor), predictedPosition)
- -- Draw a purple dot on the target's torso to show prediction
- local torso = character:FindFirstChild("Torso") or character:FindFirstChild("UpperTorso")
- if torso then
- local dot = Instance.new("Part")
- dot.Shape = Enum.PartType.Ball
- dot.Size = Vector3.new(0.2, 0.2, 0.2) -- Small size for the dot
- dot.Position = torso.Position
- dot.Anchored = true
- dot.CanCollide = false
- dot.Color = Color3.fromRGB(255, 0, 255) -- Purple color
- dot.Parent = workspace
- -- Fade out the dot after a short period
- game:GetService("Debris"):AddItem(dot, 1)
- end
- end
- end
- end
- -- Detect when the triangle button (Y) is pressed on the controller
- userInputService.InputBegan:Connect(function(input, gameProcessed)
- if gameProcessed then return end
- if input.UserInputType == Enum.UserInputType.Gamepad1 then
- if input.KeyCode == Enum.KeyCode.ButtonY then
- if isLockedOn then
- isLockedOn = false
- currentTargetPlayer = nil
- else
- local targetPlayer = getClosestPlayerInFOV()
- if targetPlayer then
- isLockedOn = true
- currentTargetPlayer = targetPlayer
- end
- end
- end
- end
- end)
- -- Prevent connection drop by checking if gameProcessed is false and fixing lock-on state
- userInputService.InputChanged:Connect(function(input)
- if isLockedOn and currentTargetPlayer then
- -- Only lock camera when it's necessary
- if input.UserInputType == Enum.UserInputType.MouseMovement or input.UserInputType == Enum.UserInputType.Touch then
- local targetPlayer = currentTargetPlayer
- local headPos = camera:WorldToScreenPoint(targetPlayer.Character.Head.Position)
- camera.CFrame = CFrame.new(camera.CFrame.Position, targetPlayer.Character.HumanoidRootPart.Position)
- end
- end
- end)
- -- Update the aim assist and smoothly transition to the closest player in FOV if locked
- runService.Heartbeat:Connect(function(deltaTime)
- if isLockedOn and currentTargetPlayer then
- lockOnToTarget(currentTargetPlayer, deltaTime)
- else
- if currentTargetPlayer then
- local newTargetPlayer = getClosestPlayerInFOV()
- if newTargetPlayer ~= currentTargetPlayer then
- currentTargetPlayer = newTargetPlayer
- end
- if currentTargetPlayer then
- lockOnToTarget(currentTargetPlayer, deltaTime)
- end
- end
- end
- end)
- -- Create the "Cware" logo with rainbow and fancy font
- local function createCwareLogo()
- local screenGui = Instance.new("ScreenGui")
- screenGui.Parent = gui
- local textLabel = Instance.new("TextLabel")
- textLabel.Parent = screenGui
- textLabel.Text = "Cware"
- textLabel.Font = Enum.Font.GothamBold
- textLabel.TextSize = 48
- textLabel.TextColor3 = Color3.fromRGB(255, 0, 0)
- textLabel.TextStrokeTransparency = 0.6
- textLabel.AnchorPoint = Vector2.new(0.5, 0.5)
- textLabel.Position = UDim2.new(0.5, 0, 0.5, 0)
- textLabel.BackgroundTransparency = 1
- -- Add white outline to the text
- textLabel.TextStrokeTransparency = 0.5
- textLabel.TextStrokeColor3 = Color3.fromRGB(255, 255, 255) -- White stroke
- local function updateRainbowColor()
- while textLabel.Parent do
- local time = tick()
- local color = Color3.fromHSV(time % 6 / 6, 1, 1)
- textLabel.TextColor3 = color
- wait(0.03)
- end
- end
- local tweenInfoIn = TweenInfo.new(1, Enum.EasingStyle.Quad, Enum.EasingDirection.In)
- local tweenInfoOut = TweenInfo.new(1, Enum.EasingStyle.Quad, Enum.EasingDirection.Out, 0, false, 0)
- local fadeIn = tweenService:Create(textLabel, tweenInfoIn, {TextTransparency = 0})
- local fadeOut = tweenService:Create(textLabel, tweenInfoOut, {TextTransparency = 1})
- fadeIn:Play()
- wait(2)
- fadeOut:Play()
- updateRainbowColor()
- wait(5)
- screenGui:Destroy()
- end
- wait(3)
- createCwareLogo()
Advertisement
Add Comment
Please, Sign In to add comment