How do I detect if a part is near a brick?

I wanted to detect when a part is near a brick.
Any help would appreciate.

you can run a loop then check the distance between the player and the brick

local part = workspace.Part -- path to your part
local distance = 5 -- How close you need to be for it to detect (studs)

while wait() do
    if (player.Character.HumanoidRootPart.Position - part.Position).magnotude < distance then
        print("Player is within 5 studs of the part")
    end
end
3 Likes