How to find the nearest part(number) the player is sitting next to?

You can use player:DistanceFromCharacter() which returns how many studs away is the vector3 from the player.

put the parts in a folder and try something like this:

local NearestPart = nil
local Lenght = nil
local Folder = workspace.Folder
local Player = game.Players.LocalPlayer

wait(10)

for i,v in pairs(Folder:GetChildren()) do
local LenghtX = Player:DistanceFromCharacter(v.Position)
	if Lenght == nil or LenghtX < Lenght then
		Lenght = LenghtX
		NearestPart = v
	end
end

print(NearestPart.name)

This script prints the name of the closest part after 10 seconds.
The NearestPart will be the nearest part to the player inside of the folder.

2 Likes