Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local player = game.Players.LocalPlayer
- local camera = workspace.CurrentCamera
- local tweenService = game:GetService("TweenService")
- -- Create the ScreenGUI
- local screenGui = Instance.new("ScreenGui", player:WaitForChild("PlayerGui"))
- screenGui.ResetOnSpawn = false
- -- Blur Effect
- local blurEffect = Instance.new("BlurEffect", camera)
- blurEffect.Size = 0
- -- Intro Text
- local introText = Instance.new("TextLabel", screenGui)
- introText.Size = UDim2.new(0, 400, 0, 100)
- introText.Position = UDim2.new(0.5, -200, 0.4, 0)
- introText.Text = "Created by Panther<3"
- introText.Font = Enum.Font.FredokaOne
- introText.TextSize = 36
- introText.TextColor3 = Color3.new(1, 1, 1) -- White
- introText.BackgroundTransparency = 1
- introText.TextTransparency = 1
- -- Toggle Button
- local button = Instance.new("TextButton", screenGui)
- button.Size = UDim2.new(0, 200, 0, 60)
- button.Position = UDim2.new(0.5, -100, 0.8, 0)
- button.Text = "Toggle: OFF"
- button.BackgroundColor3 = Color3.new(0, 0, 0) -- Black
- button.BorderColor3 = Color3.new(0.5, 0.5, 0.5) -- Gray
- button.TextColor3 = Color3.new(1, 1, 1) -- White
- button.Font = Enum.Font.GothamBlack
- button.TextSize = 30
- button.Draggable = true -- Enable dragging
- local toggle = false
- local targetPlayer = nil
- local trackingTask = nil
- local smoothingSpeed = 8 -- Controls the smoothness of camera transition
- local fovThreshold = 0.75 -- Threshold for the field of view (1.0 = 180 degrees)
- -- Function to Get Nearest Player in Front
- local function getNearestPlayer()
- local nearestPlayer = nil
- local shortestDistance = math.huge
- for _, otherPlayer in pairs(game.Players:GetPlayers()) do
- if otherPlayer ~= player and otherPlayer.Character and otherPlayer.Character:FindFirstChild("HumanoidRootPart") then
- local character = otherPlayer.Character
- local targetPosition = character.HumanoidRootPart.Position
- local distance = (player.Character.HumanoidRootPart.Position - targetPosition).Magnitude
- -- Calculate the direction to the target and check if it's within the FOV
- local cameraDirection = camera.CFrame.LookVector
- local directionToTarget = (targetPosition - camera.CFrame.Position).Unit
- local dotProduct = cameraDirection:Dot(directionToTarget)
- if distance < shortestDistance and dotProduct > fovThreshold then
- shortestDistance = distance
- nearestPlayer = otherPlayer
- end
- end
- end
- return nearestPlayer
- end
- -- Function to Track the Target with Smoothing
- local function startTracking()
- while toggle do
- if targetPlayer and targetPlayer.Character and targetPlayer.Character:FindFirstChild("HumanoidRootPart") then
- local targetPart = targetPlayer.Character.HumanoidRootPart
- local predictedPosition = targetPart.Position + (targetPart.Velocity * 0.155)
- -- Smoothly transition the camera to the predicted position
- local currentCameraPos = camera.CFrame.Position
- local smoothedPosition = currentCameraPos:Lerp(predictedPosition, 1 / smoothingSpeed)
- camera.CFrame = CFrame.new(smoothedPosition, predictedPosition)
- end
- task.wait(0.03) -- Smooth updates
- end
- end
- -- Animation: Blur and Intro Text
- local function playIntroAnimation()
- local blurTween = tweenService:Create(blurEffect, TweenInfo.new(2, Enum.EasingStyle.Quad, Enum.EasingDirection.Out), { Size = 24 })
- local textTween = tweenService:Create(introText, TweenInfo.new(2, Enum.EasingStyle.Quad, Enum.EasingDirection.Out), { TextTransparency = 0 })
- blurTween:Play()
- textTween:Play()
- textTween.Completed:Wait()
- task.wait(2)
- local fadeOutTween = tweenService:Create(introText, TweenInfo.new(1, Enum.EasingStyle.Quad, Enum.EasingDirection.In), { TextTransparency = 1 })
- local blurFadeOutTween = tweenService:Create(blurEffect, TweenInfo.new(1, Enum.EasingStyle.Quad, Enum.EasingDirection.In), { Size = 0 })
- fadeOutTween:Play()
- blurFadeOutTween:Play()
- fadeOutTween.Completed:Wait()
- introText:Destroy()
- blurEffect:Destroy()
- end
- -- Call Animation
- playIntroAnimation()
- -- Button Toggle Logic
- button.MouseButton1Click:Connect(function()
- toggle = not toggle
- button.Text = toggle and "Toggle: ON" or "Toggle: OFF"
- if toggle then
- -- Lock onto the nearest player when tracking starts
- targetPlayer = getNearestPlayer()
- if targetPlayer then
- startTracking()
- else
- toggle = false
- button.Text = "Toggle: OFF"
- end
- else
- targetPlayer = nil -- Stop tracking when toggle is off
- end
- end)
Advertisement
Add Comment
Please, Sign In to add comment