
20.5k Views
3 Executions
Does it work?
No reports yetNo reports yet. Tried it? Be the first to say.
Also noticed:
Description
detect object
local player = game.Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local rootPart = character:WaitForChild("HumanoidRootPart")
local radius = 20 -- radius to you humanoid and object stud
local function getFullPath(object)
local path = object.Name
local parent = object.Parent
while parent do
path = parent.Name .. "." .. path
parent = parent.Parent
end
return path
end
local function checkNearbyObjects()
for _, obj in pairs(workspace:GetDescendants()) do
if obj:IsA("BasePart") then
local distance = (obj.Position - rootPart.Position).Magnitude
if distance <= radius then
local fullPath = getFullPath(obj)
print("Object name: " .. obj.Name .. " | Path: " .. fullPath .. " | Distance: " .. distance) -- print
end
end
end
end
while true do
checkNearbyObjects()
wait(2) -- delayy
end
Comments
0Log in to join the conversation. Login
No comments yet. Be the first!








