Tigy1

Untitled

Dec 2nd, 2024 (edited)
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.70 KB | None | 0 0
  1. local player = game.Players.LocalPlayer
  2. local camera = workspace.CurrentCamera
  3. local tweenService = game:GetService("TweenService")
  4.  
  5. -- Create the ScreenGUI
  6. local screenGui = Instance.new("ScreenGui", player:WaitForChild("PlayerGui"))
  7. screenGui.ResetOnSpawn = false
  8.  
  9. -- Blur Effect
  10. local blurEffect = Instance.new("BlurEffect", camera)
  11. blurEffect.Size = 0
  12.  
  13. -- Intro Text
  14. local introText = Instance.new("TextLabel", screenGui)
  15. introText.Size = UDim2.new(0, 400, 0, 100)
  16. introText.Position = UDim2.new(0.5, -200, 0.4, 0)
  17. introText.Text = "Created by Panther<3"
  18. introText.Font = Enum.Font.FredokaOne
  19. introText.TextSize = 36
  20. introText.TextColor3 = Color3.new(1, 1, 1) -- White
  21. introText.BackgroundTransparency = 1
  22. introText.TextTransparency = 1
  23.  
  24. -- Toggle Button
  25. local button = Instance.new("TextButton", screenGui)
  26. button.Size = UDim2.new(0, 200, 0, 60)
  27. button.Position = UDim2.new(0.5, -100, 0.8, 0)
  28. button.Text = "Toggle: OFF"
  29. button.BackgroundColor3 = Color3.new(0, 0, 0) -- Black
  30. button.BorderColor3 = Color3.new(0.5, 0.5, 0.5) -- Gray
  31. button.TextColor3 = Color3.new(1, 1, 1) -- White
  32. button.Font = Enum.Font.GothamBlack
  33. button.TextSize = 30
  34. button.Draggable = true -- Enable dragging
  35.  
  36. local toggle = false
  37. local targetPlayer = nil
  38. local trackingTask = nil
  39. local smoothingSpeed = 8 -- Controls the smoothness of camera transition
  40. local fovThreshold = 0.75 -- Threshold for the field of view (1.0 = 180 degrees)
  41.  
  42. -- Function to Get Nearest Player in Front
  43. local function getNearestPlayer()
  44. local nearestPlayer = nil
  45. local shortestDistance = math.huge
  46.  
  47. for _, otherPlayer in pairs(game.Players:GetPlayers()) do
  48. if otherPlayer ~= player and otherPlayer.Character and otherPlayer.Character:FindFirstChild("HumanoidRootPart") then
  49. local character = otherPlayer.Character
  50. local targetPosition = character.HumanoidRootPart.Position
  51. local distance = (player.Character.HumanoidRootPart.Position - targetPosition).Magnitude
  52.  
  53. -- Calculate the direction to the target and check if it's within the FOV
  54. local cameraDirection = camera.CFrame.LookVector
  55. local directionToTarget = (targetPosition - camera.CFrame.Position).Unit
  56. local dotProduct = cameraDirection:Dot(directionToTarget)
  57.  
  58. if distance < shortestDistance and dotProduct > fovThreshold then
  59. shortestDistance = distance
  60. nearestPlayer = otherPlayer
  61. end
  62. end
  63. end
  64.  
  65. return nearestPlayer
  66. end
  67.  
  68. -- Function to Track the Target with Smoothing
  69. local function startTracking()
  70. while toggle do
  71. if targetPlayer and targetPlayer.Character and targetPlayer.Character:FindFirstChild("HumanoidRootPart") then
  72. local targetPart = targetPlayer.Character.HumanoidRootPart
  73. local predictedPosition = targetPart.Position + (targetPart.Velocity * 0.155)
  74.  
  75. -- Smoothly transition the camera to the predicted position
  76. local currentCameraPos = camera.CFrame.Position
  77. local smoothedPosition = currentCameraPos:Lerp(predictedPosition, 1 / smoothingSpeed)
  78. camera.CFrame = CFrame.new(smoothedPosition, predictedPosition)
  79. end
  80. task.wait(0.03) -- Smooth updates
  81. end
  82. end
  83.  
  84. -- Animation: Blur and Intro Text
  85. local function playIntroAnimation()
  86. local blurTween = tweenService:Create(blurEffect, TweenInfo.new(2, Enum.EasingStyle.Quad, Enum.EasingDirection.Out), { Size = 24 })
  87. local textTween = tweenService:Create(introText, TweenInfo.new(2, Enum.EasingStyle.Quad, Enum.EasingDirection.Out), { TextTransparency = 0 })
  88.  
  89. blurTween:Play()
  90. textTween:Play()
  91.  
  92. textTween.Completed:Wait()
  93. task.wait(2)
  94.  
  95. local fadeOutTween = tweenService:Create(introText, TweenInfo.new(1, Enum.EasingStyle.Quad, Enum.EasingDirection.In), { TextTransparency = 1 })
  96. local blurFadeOutTween = tweenService:Create(blurEffect, TweenInfo.new(1, Enum.EasingStyle.Quad, Enum.EasingDirection.In), { Size = 0 })
  97.  
  98. fadeOutTween:Play()
  99. blurFadeOutTween:Play()
  100.  
  101. fadeOutTween.Completed:Wait()
  102. introText:Destroy()
  103. blurEffect:Destroy()
  104. end
  105.  
  106. -- Call Animation
  107. playIntroAnimation()
  108.  
  109. -- Button Toggle Logic
  110. button.MouseButton1Click:Connect(function()
  111. toggle = not toggle
  112. button.Text = toggle and "Toggle: ON" or "Toggle: OFF"
  113.  
  114. if toggle then
  115. -- Lock onto the nearest player when tracking starts
  116. targetPlayer = getNearestPlayer()
  117. if targetPlayer then
  118. startTracking()
  119. else
  120. toggle = false
  121. button.Text = "Toggle: OFF"
  122. end
  123. else
  124. targetPlayer = nil -- Stop tracking when toggle is off
  125. end
  126. end)
  127.  
  128.  
  129.  
Advertisement
Add Comment
Please, Sign In to add comment