Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local Players = game:GetService("Players")
- local Workspace = game:GetService("Workspace")
- local RunService = game:GetService("RunService")
- local plr = Players.LocalPlayer
- -- === CONFIG ===
- local TARGET_NAME = "Rim"
- local TARGET_SIZE = Vector3.new(3.632131576538086, 0.35878971219062805, 3.632131576538086)
- local SEARCH_RADIUS = 120
- local Targets = {}
- local Markers = {}
- local selectedTarget
- -- === VISUAL MARKER ===
- local function makeMarker(part)
- 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 = 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") and v.Name == TARGET_NAME and v.Size == TARGET_SIZE then
- table.insert(Targets, v)
- if not Markers[v] then
- makeMarker(v)
- end
- end
- end
- end
- -- === INITIALIZE ===
- findAllTargets()
- -- === AUTO-UPDATES ===
- Workspace.DescendantAdded:Connect(function(o)
- if o:IsA("BasePart") and o.Name == TARGET_NAME and o.Size == TARGET_SIZE then
- table.insert(Targets, o)
- makeMarker(o)
- end
- end)
- Workspace.DescendantRemoving:Connect(function(o)
- for i, part in ipairs(Targets) do
- if part == o then
- table.remove(Targets, i)
- break
- end
- end
- removeMarker(o)
- if selectedTarget == 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 _, part in ipairs(Targets) do
- if part:IsDescendantOf(Workspace) then
- local dist = (part.Position - root.Position).Magnitude
- if dist < bestDist then
- best, bestDist = part, dist
- end
- end
- updateMarker(part)
- end
- if best and best ~= selectedTarget then
- selectedTarget = best
- print("[dunkDetect] Selected:", best:GetFullName(), string.format("(%.1f studs away)", bestDist))
- end
- -- Visual cue for selected target
- for part, marker in pairs(Markers) do
- if part == selectedTarget then
- marker.Color = Color3.fromRGB(255, 255, 0)
- marker.Size = Vector3.new(0.45, 0.45, 0.45)
- else
- marker.Color = 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