Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- 🏀 Multi-Target Dunk Detector (v2)
- local Players = game:GetService("Players")
- local Workspace = game:GetService("Workspace")
- local plr = Players.LocalPlayer
- -- === CONFIG ===
- -- Add as many targets as you want: each entry is { Name = "...", Size = Vector3.new(...), Color = Color3.fromRGB(...) }
- local TARGET_PROFILES = {
- { Name = "Rim", Size = Vector3.new(3.632131576538086, 0.5587897300720215, 3.632131576538086), Color = Color3.fromRGB(0, 255, 0) }
- }
- local SEARCH_RADIUS = 120
- local Targets, Markers = {}, {}
- local selectedTarget
- -- === HELPERS ===
- local function fuzzyEq(a: Vector3, b: Vector3, eps: number)
- eps = eps or 0.05
- return math.abs(a.X - b.X) <= eps and math.abs(a.Y - b.Y) <= eps and math.abs(a.Z - b.Z) <= eps
- end
- local function matchProfile(part)
- for _, prof in ipairs(TARGET_PROFILES) do
- if part.Name == prof.Name and fuzzyEq(part.Size, prof.Size, 0.05) then
- return prof
- end
- end
- return nil
- end
- -- === MARKER HANDLING ===
- local function makeMarker(part, color)
- local marker = Instance.new("Part")
- marker.Shape = Enum.PartType.Ball
- marker.Size = Vector3.new(0.35, 0.35, 0.35)
- marker.Material = Enum.Material.Neon
- marker.Color = color or Color3.fromRGB(0, 255, 0)
- marker.Anchored = true
- marker.CanCollide = false
- marker.Parent = Workspace
- Markers[part] = marker
- end
- local function updateMarker(part)
- local marker = Markers[part]
- if marker and part:IsDescendantOf(Workspace) then
- marker.Position = part.Position + Vector3.new(0, 2.5, 0)
- end
- end
- local function removeMarker(part)
- local marker = Markers[part]
- if marker then
- marker:Destroy()
- Markers[part] = nil
- end
- end
- -- === SCANNER ===
- local function findAllTargets()
- table.clear(Targets)
- for _, v in ipairs(Workspace:GetDescendants()) do
- if v:IsA("BasePart") then
- local prof = matchProfile(v)
- if prof then
- table.insert(Targets, { part = v, profile = prof })
- if not Markers[v] then
- makeMarker(v, prof.Color)
- end
- end
- end
- end
- end
- -- === INITIALIZE ===
- findAllTargets()
- -- === DYNAMIC UPDATES ===
- Workspace.DescendantAdded:Connect(function(o)
- if o:IsA("BasePart") then
- local prof = matchProfile(o)
- if prof then
- table.insert(Targets, { part = o, profile = prof })
- makeMarker(o, prof.Color)
- end
- end
- end)
- Workspace.DescendantRemoving:Connect(function(o)
- for i, data in ipairs(Targets) do
- if data.part == o then
- table.remove(Targets, i)
- break
- end
- end
- removeMarker(o)
- if selectedTarget and selectedTarget.part == o then
- selectedTarget = nil
- end
- end)
- -- === TRACKING LOOP ===
- task.spawn(function()
- while task.wait(0.1) do
- local root = plr.Character and plr.Character:FindFirstChild("HumanoidRootPart")
- if not root then continue end
- local best, bestDist = nil, SEARCH_RADIUS
- for _, data in ipairs(Targets) do
- local part, prof = data.part, data.profile
- if part:IsDescendantOf(Workspace) then
- local dist = (part.Position - root.Position).Magnitude
- if dist < bestDist then
- best, bestDist = data, dist
- end
- end
- updateMarker(part)
- end
- if best and best ~= selectedTarget then
- selectedTarget = best
- print(string.format("[Tracker] %s selected (%.1f studs away)", best.part:GetFullName(), bestDist))
- end
- -- Visual cue for nearest target
- for part, marker in pairs(Markers) do
- if selectedTarget and part == selectedTarget.part then
- marker.Color = Color3.fromRGB(255, 255, 0)
- marker.Size = Vector3.new(0.45, 0.45, 0.45)
- else
- -- Reset to its profile’s color
- local prof = matchProfile(part)
- marker.Color = (prof and prof.Color) or Color3.fromRGB(0, 255, 0)
- marker.Size = Vector3.new(0.35, 0.35, 0.35)
- end
- end
- end
- end)
Advertisement
Add Comment
Please, Sign In to add comment