ColdSpecs

Complete Push + Aim (Now needs power support)

Nov 2nd, 2025
38
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 14.92 KB | None | 0 0
  1. --// ======================================================================
  2. --// PAYLOAD0 • AUTO-AIM + ALIGN-ASSIST SYSTEM [STATIC RIMSIZE VERSION]
  3. --// • Auto-locks static rims by exact RimSize
  4. --// • Smart aim shooting logic (legacy + new shoot_event support)
  5. --// • Pushback assist active ONLY when player holds a ball
  6. --// • Bright green visuals show ONLY when ball is equipped & within zone
  7. --// • Calibration UI shows ONLY when holding a ball + key missing
  8. --// • Visuals toggle [O], System toggle [V]
  9. --// ======================================================================
  10.  
  11. -- === SERVICES ===
  12. local Players = game:GetService('Players')
  13. local UserInputService = game:GetService('UserInputService')
  14. local RunService = game:GetService('RunService')
  15. local ReplicatedStorage = game:GetService('ReplicatedStorage')
  16. local CoreGui = game:GetService('CoreGui')
  17. local TweenService = game:GetService('TweenService')
  18. local Workspace = game:GetService('Workspace')
  19. local Camera = workspace.CurrentCamera
  20.  
  21. local plr = Players.LocalPlayer
  22. local char = plr.Character or plr.CharacterAdded:Wait()
  23.  
  24. -- === STATE ===
  25. getgenv().PAYLOAD0_SYSTEM_ACTIVE = true
  26. local VisualsEnabled = true
  27. local shootKey : string? = nil
  28. local selectedRim : BasePart? = nil
  29. local activeNotifyGui
  30. local ballTool : Tool? = nil
  31.  
  32. -- === CONFIGURATION ===
  33. local PERFECT_DISTANCES = { 54.97, 61.53, 68.10 }
  34. local CLAMP_RADIUS = 1
  35. local ACTIVE_RANGE_MAIN = 90
  36. local MAX_PUSH = 0.06
  37. local DAMPING = 0.9
  38. local SHOOT_POWER = 30 -- used for new Workspace shoot_event
  39.  
  40. local COLOR_GREEN = Color3.fromRGB(0, 255, 100)
  41. local COLOR_GREEN_SOFT = Color3.fromRGB(0, 200, 80)
  42.  
  43. -- === NOTIFY SYSTEM ===
  44. local function notify(msg, color)
  45. if activeNotifyGui and activeNotifyGui.Parent then
  46. activeNotifyGui:Destroy()
  47. end
  48. local gui = Instance.new('ScreenGui')
  49. gui.ResetOnSpawn = false
  50. gui.Parent = CoreGui
  51. activeNotifyGui = gui
  52.  
  53. local label = Instance.new('TextLabel')
  54. label.AnchorPoint = Vector2.new(0.5, 0.5)
  55. label.BackgroundTransparency = 1
  56. label.TextColor3 = color or Color3.fromRGB(255, 255, 255)
  57. label.Font = Enum.Font.Code
  58. label.TextSize = 26
  59. label.Text = msg
  60. label.Position = UDim2.new(0.5, 0, 0.9, 0)
  61. label.Parent = gui
  62.  
  63. task.spawn(function()
  64. task.wait(1.2)
  65. if gui == activeNotifyGui then
  66. gui:Destroy()
  67. activeNotifyGui = nil
  68. end
  69. end)
  70. end
  71.  
  72. -- === HELPER: BALL CHECK ===
  73. local function hasBall()
  74. local c = plr.Character
  75. if not c then return false end
  76. for _, tool in ipairs(c:GetChildren()) do
  77. if tool:IsA('Tool') and tool.Name:lower():find('ball') then
  78. ballTool = tool
  79. return true
  80. end
  81. end
  82. ballTool = nil
  83. return false
  84. end
  85.  
  86. -- === CALIBRATE UI (ONLY WHEN HOLDING BALL + NO KEY) ===
  87. local calibrateGui
  88. local function showCalibrateUI()
  89. if calibrateGui or shootKey or not hasBall() then return end
  90.  
  91. calibrateGui = Instance.new('ScreenGui')
  92. calibrateGui.Name = 'CalibrateReminder'
  93. calibrateGui.ResetOnSpawn = false
  94. calibrateGui.IgnoreGuiInset = true
  95. calibrateGui.Parent = CoreGui
  96.  
  97. local frame = Instance.new('Frame')
  98. frame.AnchorPoint = Vector2.new(0.5, 0.5)
  99. frame.Position = UDim2.new(0.5, 0, 0.85, 0)
  100. frame.Size = UDim2.new(0, 420, 0, 45)
  101. frame.BackgroundTransparency = 0.3
  102. frame.BackgroundColor3 = Color3.fromRGB(20, 20, 20)
  103. frame.BorderSizePixel = 0
  104. frame.Parent = calibrateGui
  105.  
  106. local stroke = Instance.new('UIStroke')
  107. stroke.Color = Color3.fromRGB(80, 255, 120)
  108. stroke.Thickness = 1.6
  109. stroke.Parent = frame
  110.  
  111. local corner = Instance.new('UICorner')
  112. corner.CornerRadius = UDim.new(0, 10)
  113. corner.Parent = frame
  114.  
  115. local label = Instance.new('TextLabel')
  116. label.BackgroundTransparency = 1
  117. label.Size = UDim2.new(1, 0, 1, 0)
  118. label.Font = Enum.Font.GothamMedium
  119. label.TextSize = 22
  120. label.TextColor3 = Color3.fromRGB(120, 255, 150)
  121. label.Text = '🏀 Click once to calibrate your shot.'
  122. label.Parent = frame
  123.  
  124. task.spawn(function()
  125. while calibrateGui and not shootKey and hasBall() do
  126. local t1 = TweenService:Create(label, TweenInfo.new(0.8, Enum.EasingStyle.Sine), {TextTransparency = 0.3})
  127. local t2 = TweenService:Create(label, TweenInfo.new(0.8, Enum.EasingStyle.Sine), {TextTransparency = 0})
  128. t1:Play(); t1.Completed:Wait()
  129. t2:Play(); t2.Completed:Wait()
  130. end
  131. end)
  132. end
  133.  
  134. local function removeCalibrateUI()
  135. if calibrateGui then calibrateGui:Destroy(); calibrateGui = nil end
  136. end
  137.  
  138. task.spawn(function()
  139. while task.wait(0.5) do
  140. if not hasBall() or shootKey then removeCalibrateUI() else showCalibrateUI() end
  141. end
  142. end)
  143.  
  144. --// =============================================================
  145. --// SMART REMOTE LISTENER – handles both legacy & new remotes
  146. --// =============================================================
  147. local shootRemote : RemoteEvent? = nil
  148. local hookedMeta = nil
  149. local SEARCH_PATTERN = 'shoot'
  150.  
  151. -- refresh possible roots (some games respawn containers)
  152. local function getRoots()
  153. local roots = {}
  154.  
  155. -- New pattern: Workspace.<playerName>.Basketball (per-user container)
  156. local userFolder = Workspace:FindFirstChild(plr.Name)
  157. if userFolder and userFolder:FindFirstChild('Basketball') then
  158. table.insert(roots, userFolder.Basketball)
  159. end
  160.  
  161. -- Fallback: Workspace.isokcocs.Basketball
  162. local iso = Workspace:FindFirstChild('isokcocs')
  163. if iso and iso:FindFirstChild('Basketball') then
  164. table.insert(roots, iso.Basketball)
  165. end
  166.  
  167. -- Legacy: ReplicatedStorage.Remotes.Shoot
  168. local remotes = ReplicatedStorage:FindFirstChild('Remotes')
  169. if remotes then table.insert(roots, remotes) end
  170.  
  171. return roots
  172. end
  173.  
  174. local function findShootRemote()
  175. for _, root in ipairs(getRoots()) do
  176. for _, obj in ipairs(root:GetDescendants()) do
  177. if obj:IsA('RemoteEvent') and obj.Name:lower():find(SEARCH_PATTERN) then
  178. return obj
  179. end
  180. end
  181. -- also check direct children for legacy Shoot
  182. local direct = root:FindFirstChild('Shoot')
  183. if direct and direct:IsA('RemoteEvent') then
  184. return direct
  185. end
  186. end
  187. return nil
  188. end
  189.  
  190. local function hookRemote(remote : RemoteEvent)
  191. if hookedMeta then return end
  192. local old
  193. old = hookmetamethod(game, '__namecall', function(self, ...)
  194. local m = getnamecallmethod()
  195. if m == 'FireServer' and self == remote then
  196. local args = {...}
  197. if type(args[3]) == 'string' and not shootKey then
  198. shootKey = args[3]
  199. removeCalibrateUI()
  200. pcall(function() notify('Shoot key captured: '..shootKey, COLOR_GREEN) end)
  201. end
  202. end
  203. return old(self, ...)
  204. end)
  205. hookedMeta = old
  206. shootRemote = remote
  207. pcall(function() notify('Remote locked: '..remote:GetFullName(), COLOR_GREEN) end)
  208. end
  209.  
  210. local function unhookRemote()
  211. hookedMeta = nil
  212. shootRemote = nil
  213. end
  214.  
  215. RunService.Heartbeat:Connect(function()
  216. if not getgenv().PAYLOAD0_SYSTEM_ACTIVE then return end
  217. local current = findShootRemote()
  218. if current then
  219. if current ~= shootRemote then
  220. unhookRemote()
  221. hookRemote(current)
  222. end
  223. elseif shootRemote then
  224. unhookRemote()
  225. end
  226. end)
  227.  
  228. -- === HIGHLIGHT VISUAL ===
  229. local hl = CoreGui:FindFirstChild('PerfectRangeGlow') or Instance.new('Highlight')
  230. hl.Name = 'PerfectRangeGlow'
  231. hl.DepthMode = Enum.HighlightDepthMode.AlwaysOnTop
  232. hl.FillTransparency = 0.25
  233. hl.OutlineTransparency = 0
  234. hl.Adornee = plr.Character
  235. hl.Parent = CoreGui
  236. hl.Enabled = false
  237.  
  238. -- === TOGGLES ===
  239. UserInputService.InputBegan:Connect(function(i, gp)
  240. if gp then return end
  241. if i.KeyCode == Enum.KeyCode.O then
  242. VisualsEnabled = not VisualsEnabled
  243. notify(VisualsEnabled and '👁 Visuals ON' or '🙈 Visuals OFF',
  244. VisualsEnabled and COLOR_GREEN or Color3.fromRGB(255,80,80))
  245. elseif i.KeyCode == Enum.KeyCode.V then
  246. getgenv().PAYLOAD0_SYSTEM_ACTIVE = not getgenv().PAYLOAD0_SYSTEM_ACTIVE
  247. notify(getgenv().PAYLOAD0_SYSTEM_ACTIVE and '✅ System ON' or '🚫 System OFF',
  248. getgenv().PAYLOAD0_SYSTEM_ACTIVE and COLOR_GREEN or Color3.fromRGB(255,80,80))
  249. end
  250. end)
  251.  
  252. -- === SHOOT LOGIC HELPERS ===
  253. local lastTick, moveOffset = 0, Vector3.zero
  254. local function computeOffset()
  255. if tick() - lastTick > 0.1 then
  256. local hum = plr.Character and plr.Character:FindFirstChildOfClass('Humanoid')
  257. local moveDir = (hum and hum.MoveDirection) or Vector3.zero
  258. moveOffset = Vector3.new(moveDir.X * 1.5, 0, moveDir.Z * 1.5)
  259. lastTick = tick()
  260. end
  261. return moveOffset
  262. end
  263.  
  264. local function computeArc(dist) return Vector3.new(0, 43 + (dist / 15), 0) end
  265.  
  266. local function smartAim(rim)
  267. local offset = computeOffset()
  268. local root = plr.Character and plr.Character:FindFirstChild('HumanoidRootPart')
  269. if not root then return rim.Position end
  270. local dist = (root.Position - rim.Position).Magnitude
  271. return rim.Position + computeArc(dist) - offset
  272. end
  273.  
  274. -- Fire helper that adapts to remote flavor
  275. local function fireShootRemote(aimPos, shootFrom)
  276. if not shootRemote then return end
  277. -- New event usually named "shoot_event" in Workspace with richer payload
  278. if shootRemote.Name:lower():find('shoot') and shootRemote.Parent and shootRemote.Parent:IsDescendantOf(Workspace) then
  279. local char = plr.Character
  280. local root = char and char.PrimaryPart
  281. local head = char and char:FindFirstChild('Head')
  282. if not (char and root and head) then return end
  283. local dir = (aimPos - head.Position).Unit
  284.  
  285. -- camera / state table (loose; server typically validates leniently)
  286. local stateTable = {
  287. CFrame = root.CFrame,
  288. FieldOfView = Camera.FieldOfView,
  289. ViewportSize = Camera.ViewportSize,
  290. }
  291.  
  292. -- prefer the equipped tool for arg4
  293. local tool = ballTool or (char and char:FindFirstChildOfClass('Tool'))
  294.  
  295. shootRemote:FireServer(
  296. aimPos, -- 1 target
  297. shootFrom or (root.Position + dir * 4), -- 2 origin
  298. shootKey, -- 3 key captured via hook
  299. tool, -- 4 ball tool (if required)
  300. SHOOT_POWER, -- 5 power
  301. stateTable, -- 6 state
  302. true -- 7 confirm
  303. )
  304. else
  305. -- Legacy ReplicatedStorage.Remotes.Shoot(aimPos, from, key)
  306. shootRemote:FireServer(aimPos, shootFrom, shootKey)
  307. end
  308. end
  309.  
  310. local function shootAtTarget()
  311. if not getgenv().PAYLOAD0_SYSTEM_ACTIVE then return end
  312. if not (selectedRim and selectedRim:IsDescendantOf(Workspace)) then return end
  313. if not shootKey then return end
  314. if not shootRemote then return end
  315.  
  316. local char = plr.Character
  317. if not char then return end
  318. local head, root = char:FindFirstChild('Head'), char.PrimaryPart
  319. if not (head and root) then return end
  320.  
  321. local aimPos = smartAim(selectedRim)
  322. local dir = (aimPos - head.Position).Unit
  323. local shootFrom = root.Position + dir * 3.8
  324. if shootFrom.Y - root.Position.Y < 4 then
  325. shootFrom = root.Position + dir * 4
  326. end
  327. fireShootRemote(aimPos, shootFrom)
  328. end
  329.  
  330. UserInputService.InputBegan:Connect(function(i, gp)
  331. if gp or not getgenv().PAYLOAD0_SYSTEM_ACTIVE then return end
  332. if i.UserInputType == Enum.UserInputType.MouseButton1 and hasBall() then
  333. shootAtTarget()
  334. end
  335. end)
  336.  
  337. -- === MOVEMENT KEYS FOR PUSH ===
  338. local moveKeys = { W = false, A = false, S = false, D = false }
  339. UserInputService.InputBegan:Connect(function(i, gp)
  340. if gp then return end
  341. local k = i.KeyCode.Name
  342. if moveKeys[k] ~= nil then moveKeys[k] = true end
  343. end)
  344. UserInputService.InputEnded:Connect(function(i, gp)
  345. if gp then return end
  346. local k = i.KeyCode.Name
  347. if moveKeys[k] ~= nil then moveKeys[k] = false end
  348. end)
  349.  
  350. local function shouldPush()
  351. local count = 0
  352. for _, v in pairs(moveKeys) do if v then count += 1 end end
  353. return count == 1 and (moveKeys.A or moveKeys.D)
  354. end
  355.  
  356. --// ======================================================================
  357. --// STATIC RIMSIZE DETECTION + ALIGN ASSIST
  358. --// ======================================================================
  359. local RimSize = Vector3.new(3.632131576538086, 0.5587897300720215, 3.632131576538086)
  360. local Rims = {}
  361.  
  362. -- Initial population
  363. for _, v in ipairs(Workspace:GetDescendants()) do
  364. if v:IsA('BasePart') and v.Name == 'Rim' and v.Size == RimSize then
  365. table.insert(Rims, v)
  366. end
  367. end
  368.  
  369. -- Maintain live list
  370. Workspace.DescendantAdded:Connect(function(o)
  371. if o:IsA('BasePart') and o.Name == 'Rim' and o.Size == RimSize then
  372. table.insert(Rims, o)
  373. end
  374. end)
  375. Workspace.DescendantRemoving:Connect(function(o)
  376. for i, rim in ipairs(Rims) do
  377. if rim == o then table.remove(Rims, i); break end
  378. end
  379. if selectedRim == o then selectedRim = nil end
  380. end)
  381.  
  382. -- Pick closest rim (XZ plane)
  383. local function nearestRim(rootPos)
  384. local nearest, nearestDist
  385. for _, rim in ipairs(Rims) do
  386. if rim:IsDescendantOf(Workspace) then
  387. local rimXZ = Vector3.new(rim.Position.X, 0, rim.Position.Z)
  388. local dist = (rimXZ - Vector3.new(rootPos.X, 0, rootPos.Z)).Magnitude
  389. if not nearestDist or dist < nearestDist then
  390. nearest, nearestDist = rim, dist
  391. end
  392. end
  393. end
  394. return nearest, nearestDist
  395. end
  396.  
  397. -- Clamp to nearest perfect distance
  398. local function getNearestPerfectDistance(current)
  399. local nearest, smallestDiff
  400. for _, pd in ipairs(PERFECT_DISTANCES) do
  401. local diff = math.abs(pd - current)
  402. if not smallestDiff or diff < smallestDiff then
  403. nearest, smallestDiff = pd, diff
  404. end
  405. end
  406. return nearest
  407. end
  408.  
  409. -- === ALIGN/PUSH LOOP ===
  410. local smoothBias = Vector3.zero
  411. RunService.RenderStepped:Connect(function()
  412. if not getgenv().PAYLOAD0_SYSTEM_ACTIVE then
  413. hl.Enabled = false
  414. return
  415. else
  416. hl.Enabled = VisualsEnabled
  417. end
  418.  
  419. local char = plr.Character
  420. local hum = char and char:FindFirstChildOfClass('Humanoid')
  421. local root = char and char:FindFirstChild('HumanoidRootPart')
  422. if not (hum and root) then return end
  423.  
  424. if not hasBall() then
  425. hl.Enabled = false
  426. return
  427. end
  428.  
  429. local rim, dist = nearestRim(root.Position)
  430. if not rim or dist > ACTIVE_RANGE_MAIN then
  431. hl.Enabled = false
  432. smoothBias = Vector3.zero
  433. return
  434. end
  435.  
  436. selectedRim = rim
  437.  
  438. local target = getNearestPerfectDistance(dist)
  439. local diff = dist - target
  440. local absDiff = math.abs(diff)
  441. local desired = Vector3.zero
  442.  
  443. -- One-way push only when A or D singly pressed
  444. if shouldPush() and absDiff < CLAMP_RADIUS then
  445. local strength = (CLAMP_RADIUS - absDiff) / CLAMP_RADIUS
  446. local toRim = Vector3.new(rim.Position.X, 0, rim.Position.Z) - Vector3.new(root.Position.X, 0, root.Position.Z)
  447. local distSign = math.sign(diff)
  448. if distSign > 0 then
  449. local pushDir = -toRim.Unit
  450. desired = pushDir * math.min(strength * MAX_PUSH, MAX_PUSH)
  451. end
  452. end
  453.  
  454. smoothBias = smoothBias * DAMPING + desired * (1 - DAMPING)
  455. root.CFrame += Vector3.new(smoothBias.X, 0, smoothBias.Z)
  456.  
  457. -- Visuals
  458. if not VisualsEnabled then return end
  459. if absDiff <= 0.10 then
  460. hl.FillColor, hl.OutlineColor = COLOR_GREEN, COLOR_GREEN
  461. elseif absDiff < CLAMP_RADIUS then
  462. hl.FillColor, hl.OutlineColor = COLOR_GREEN_SOFT, COLOR_GREEN_SOFT
  463. else
  464. hl.Enabled = false
  465. end
  466. end)
  467.  
  468. -- Re-attach highlight on respawn
  469. plr.CharacterAdded:Connect(function(c)
  470. task.wait(0.5)
  471. hl.Adornee = c
  472. end)
  473.  
  474. print('[🏀 PAYLOAD0 LOADED — STATIC RimSize ALIGN + SMART SHOOT + A/D SINGLE-KEY PUSH]')
  475. print('[V] Toggle system | [O] Toggle visuals | [LMB] Shoot')
  476.  
Advertisement
Add Comment
Please, Sign In to add comment