benxogian

Untitled

Dec 30th, 2024
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.50 KB | None | 0 0
  1. local player = game.Players.LocalPlayer
  2. local camera = workspace.CurrentCamera
  3. local playerGui = player:WaitForChild("PlayerGui")
  4.  
  5. local smoothSpeed = 0.9
  6. local horizontalPrediction = 0.0346 -- Horizontal prediction value
  7. local verticalPrediction = 0.0538528682685329 -- Vertical prediction value
  8. local xOffset, yOffset, zOffset = 0.0346, 0.0346, 0.0346 -- All offsets set to 0.0346
  9. local isLockedOn = false
  10. local lockedPlayer = nil
  11.  
  12. local controllerLockButton = Enum.KeyCode.ButtonY -- Triangle button for controller
  13. local device = "controller" -- Set to "controller"
  14.  
  15. local function enhancedPrediction(targetPlayer)
  16. if targetPlayer and targetPlayer.Character then
  17. local humanoidRootPart = targetPlayer.Character:FindFirstChild("HumanoidRootPart")
  18. local head = targetPlayer.Character:FindFirstChild("Head")
  19. local velocity = humanoidRootPart.Velocity
  20.  
  21. local adjustedVelocity = Vector3.new(
  22. math.clamp(velocity.X, -50, 50),
  23. math.clamp(velocity.Y, -50, 50),
  24. math.clamp(velocity.Z, -50, 50)
  25. )
  26.  
  27. local predictedPosition = humanoidRootPart.Position + adjustedVelocity * verticalPrediction
  28. predictedPosition = Vector3.new(
  29. predictedPosition.X + xOffset,
  30. predictedPosition.Y + yOffset,
  31. predictedPosition.Z + zOffset
  32. )
  33.  
  34. if adjustedVelocity.Y > 2 then
  35. if head then
  36. predictedPosition = head.Position + Vector3.new(0, 0.5, 0)
  37. end
  38. elseif adjustedVelocity.Y < -2 then
  39. predictedPosition = humanoidRootPart.Position + Vector3.new(0, -0.5, 0)
  40. end
  41.  
  42. return predictedPosition
  43. end
  44. return nil
  45. end
  46.  
  47. local function lockOn()
  48. local closestPlayer = nil
  49. local shortestDistance = math.huge
  50. local screenCenter = Vector2.new(camera.ViewportSize.X / 2, camera.ViewportSize.Y / 2)
  51.  
  52. for _, p in pairs(game.Players:GetPlayers()) do
  53. if p ~= player then
  54. local character = p.Character
  55. if character and character:FindFirstChild("HumanoidRootPart") then
  56. local head = character.HumanoidRootPart
  57. local headPos = camera:WorldToScreenPoint(head.Position)
  58.  
  59. local distance = (screenCenter - Vector2.new(headPos.X, headPos.Y)).Magnitude
  60. if distance < shortestDistance then
  61. shortestDistance = distance
  62. closestPlayer = p
  63. end
  64. end
  65. end
  66. end
  67.  
  68. if closestPlayer then
  69. lockedPlayer = closestPlayer
  70. isLockedOn = true
  71. else
  72. print("No player found to lock onto.")
  73. end
  74. end
  75.  
  76. local function smoothlyDragToPlayer(targetPlayer)
  77. if targetPlayer then
  78. local predictedPosition = enhancedPrediction(targetPlayer)
  79. if predictedPosition then
  80. local currentPosition = camera.CFrame.Position
  81. camera.CFrame = CFrame.new(currentPosition:Lerp(predictedPosition, smoothSpeed), predictedPosition)
  82. end
  83. end
  84. end
  85.  
  86. game:GetService("RunService").Heartbeat:Connect(function()
  87. if isLockedOn and lockedPlayer then
  88. smoothlyDragToPlayer(lockedPlayer)
  89. end
  90. end)
  91.  
  92. local function onKeyPress(input)
  93. if device == "controller" and input.UserInputType == Enum.UserInputType.Gamepad1 then
  94. if input.KeyCode == controllerLockButton then
  95. if isLockedOn then
  96. lockedPlayer = nil
  97. isLockedOn = false
  98. else
  99. lockOn()
  100. end
  101. end
  102. end
  103. end
  104.  
  105. game:GetService("UserInputService").InputBegan:Connect(onKeyPress)
  106.  
  107. -- Initialize the device type at the start
  108. local function setDeviceType()
  109. if game:GetService("UserInputService"):GetGamepadState(Enum.UserInputType.Gamepad1) then
  110. device = "controller"
  111. else
  112. device = "PC"
  113. end
  114. end
  115.  
  116. -- Set device type at the start
  117. setDeviceType()
  118.  
  119. -- Display UI text labels (Rainbow text and copied message) and play audio
  120. local screenGui = Instance.new("ScreenGui")
  121. local textLabel = Instance.new("TextLabel")
  122. local copiedTextLabel = Instance.new("TextLabel")
  123.  
  124. screenGui.Parent = player:WaitForChild("PlayerGui")
  125. screenGui.ResetOnSpawn = false
  126.  
  127. local function playAudio()
  128. local sound = Instance.new("Sound")
  129. sound.SoundId = "rbxassetid://158012252"
  130. sound.Parent = game.Workspace
  131. sound:Play()
  132. end
  133.  
  134. local function displayTextAtTop()
  135. textLabel.Text = "Cware"
  136. textLabel.Position = UDim2.new(0.5, -75, 0, 10)
  137. textLabel.Size = UDim2.new(0, 150, 0, 50)
  138. textLabel.TextSize = 30
  139. textLabel.TextColor3 = Color3.fromRGB(255, 0, 0)
  140. textLabel.BackgroundTransparency = 1
  141. textLabel.TextTransparency = 0
  142. textLabel.TextStrokeTransparency = 0.8
  143. textLabel.TextStrokeColor3 = Color3.fromRGB(255, 255, 255)
  144. textLabel.Font = Enum.Font.GothamBold
  145. textLabel.Parent = screenGui
  146.  
  147. local function makeRainbowText()
  148. local colors = {Color3.fromRGB(255, 0, 0), Color3.fromRGB(255, 165, 0), Color3.fromRGB(255, 255, 0), Color3.fromRGB(0, 255, 0), Color3.fromRGB(0, 0, 255), Color3.fromRGB(75, 0, 130), Color3.fromRGB(238, 130, 238)}
  149. local index = 1
  150. while true do
  151. textLabel.TextColor3 = colors[index]
  152. index = index + 1
  153. if index > #colors then
  154. index = 1
  155. end
  156. wait(0.1)
  157. end
  158. end
  159.  
  160. coroutine.wrap(makeRainbowText)()
  161. end
  162.  
  163. local function displayCopiedText()
  164. copiedTextLabel.Text = "COPIED DISCORD LINK JOIN FOR UPDATES!"
  165. copiedTextLabel.Position = UDim2.new(0.5, -150, 0, -40)
  166. copiedTextLabel.Size = UDim2.new(0, 300, 0, 30)
  167. copiedTextLabel.TextSize = 14
  168. copiedTextLabel.TextColor3 = Color3.fromRGB(255, 255, 255)
  169. copiedTextLabel.BackgroundTransparency = 1
  170. copiedTextLabel.TextTransparency = 0
  171. copiedTextLabel.TextStrokeTransparency = 0.8
  172. copiedTextLabel.TextStrokeColor3 = Color3.fromRGB(255, 255, 255)
  173. copiedTextLabel.Font = Enum.Font.GothamBold
  174. copiedTextLabel.Parent = screenGui
  175.  
  176. wait(4)
  177. copiedTextLabel:TweenTransparency(1, Enum.EasingStyle.Linear, Enum.EasingDirection.In, 1, true)
  178. end
  179.  
  180. local function copyDiscordLink()
  181. setclipboard("https://discord.gg/HwTmqpfwft")
  182. end
  183.  
  184. playAudio()
  185. copyDiscordLink()
  186. displayTextAtTop()
  187. displayCopiedText()
  188.  
  189. player.CharacterAdded:Connect(function()
  190. -- When the character respawns, initialize device type and lock functionality
  191. setDeviceType()
  192. end)
Advertisement
Add Comment
Please, Sign In to add comment