Here's the code for the function that finds the nearest character:

function findNearestCharacter()
	local closestCharacter = nil
	local closestDistance = math.huge
	for _, character in pairs(game.Workspace:GetChildren()) do
		if character:IsA("Model") and character ~= game.Players.LocalPlayer.Character then
			local distance = (character.HumanoidRootPart.Position - game.Players.LocalPlayer.Character.HumanoidRootPart.Position).magnitude
			if distance < closestDistance then
				closestCharacter = character
				closestDistance = distance
			end
		end
	end
	return closestCharacter
end

And here's the main code that uses the findNearestCharacter function to teleport the player to the nearest character:

local closestCharacter = findNearestCharacter()
if closestCharacter then
	game.Players.LocalPlayer.Character.HumanoidRootPart.CFrame = closestCharacter.HumanoidRootPart.CFrame
end
Here's the code for the function that finds the nearest character:

function findNearestCharacter()
	local closestCharacter = nil
	local closestDistance = math.huge
	for _, character in pairs(game.Workspace:GetChildren()) do
		if character:IsA("Model") and character ~= game.Players.LocalPlayer.Character then
			local distance = (character.HumanoidRootPart.Position - game.Players.LocalPlayer.Character.HumanoidRootPart.Position).magnitude
			if distance < closestDistance then
				closestCharacter = character
				closestDistance = distance
			end
		end
	end
	return closestCharacter
end

And here's the main code that uses the findNearestCharacter function to teleport the player to the nearest character:

local closestCharacter = findNearestCharacter()
if closestCharacter then
	game.Players.LocalPlayer.Character.HumanoidRootPart.CFrame = closestCharacter.HumanoidRootPart.CFrame
end
user
Here's the code for the function that finds the nearest character:

function findNearestCharacter()
	local closestCharacter = nil
	local closestDistance = math.huge
	for _, character in pairs(game.Workspace:GetChildren()) do
		if character:IsA("Model") and character ~= game.Players.LocalPlayer.Character then
			local distance = (character.HumanoidRootPart.Position - game.Players.LocalPlayer.Character.HumanoidRootPart.Position).magnitude
			if distance < closestDistance then
				closestCharacter = character
				closestDistance = distance
			end
		end
	end
	return closestCharacter
end

And here's the main code that uses the findNearestCharacter function to teleport the player to the nearest character:

local closestCharacter = findNearestCharacter()
if closestCharacter then
	game.Players.LocalPlayer.Character.HumanoidRootPart.CFrame = closestCharacter.HumanoidRootPart.CFrame
end
assistant
Here's the code for the function that finds the nearest character:

function findNearestCharacter()
	local closestCharacter = nil
	local closestDistance = math.huge
	for _, character in pairs(game.Workspace:GetChildren()) do
		if character:IsA("Model") and character ~= game.Players.LocalPlayer.Character then
			local distance = (character.HumanoidRootPart.Position - game.Players.LocalPlayer.Character.HumanoidRootPart.Position).magnitude
			if distance < closestDistance then
				closestCharacter = character
				closestDistance = distance
			end
		end
	end
	return closestCharacter
end

And here's the main code that uses the findNearestCharacter function to teleport the player to the nearest character:

local closestCharacter = findNearestCharacter()
if closestCharacter then
	game.Players.LocalPlayer.Character.HumanoidRootPart.CFrame = closestCharacter.HumanoidRootPart.CFrame
end
user
Here's the code for the function that finds the nearest character:

function findNearestCharacter()
	local closestCharacter = nil
	local closestDistance = math.huge
	for _, character in pairs(game.Workspace:GetChildren()) do
		if character:IsA("Model") and character ~= game.Players.LocalPlayer.Character then
			local distance = (character.HumanoidRootPart.Position - game.Players.LocalPlayer.Character.HumanoidRootPart.Position).magnitude
			if distance < closestDistance then
				closestCharacter = character
				closestDistance = distance
			end
		end
	end
	return closestCharacter
end

And here's the main code that uses the findNearestCharacter function to teleport the player to the nearest character:

local closestCharacter = findNearestCharacter()
if closestCharacter then
	game.Players.LocalPlayer.Character.HumanoidRootPart.CFrame = closestCharacter.HumanoidRootPart.CFrame
end
assistant
Here's the code for the function that finds the nearest character:

function findNearestCharacter()
	local closestCharacter = nil
	local closestDistance = math.huge
	for _, character in pairs(game.Workspace:GetChildren()) do
		if character:IsA("Model") and character ~= game.Players.LocalPlayer.Character then
			local distance = (character.HumanoidRootPart.Position - game.Players.LocalPlayer.Character.HumanoidRootPart.Position).magnitude
			if distance < closestDistance then
				closestCharacter = character
				closestDistance = distance
			end
		end
	end
	return closestCharacter
end

And here's the main code that uses the findNearestCharacter function to teleport the player to the nearest character:

local closestCharacter = findNearestCharacter()
if closestCharacter then
	game.Players.LocalPlayer.Character.HumanoidRootPart.CFrame = closestCharacter.HumanoidRootPart.CFrame
end
user
Here's the code for the function that finds the nearest character:

function findNearestCharacter()
	local closestCharacter = nil
	local closestDistance = math.huge
	for _, character in pairs(game.Workspace:GetChildren()) do
		if character:IsA("Model") and character ~= game.Players.LocalPlayer.Character then
			local distance = (character.HumanoidRootPart.Position - game.Players.LocalPlayer.Character.HumanoidRootPart.Position).magnitude
			if distance < closestDistance then
				closestCharacter = character
				closestDistance = distance
			end
		end
	end
	return closestCharacter
end

And here's the main code that uses the findNearestCharacter function to teleport the player to the nearest character:

local closestCharacter = findNearestCharacter()
if closestCharacter then
	game.Players.LocalPlayer.Character.HumanoidRootPart.CFrame = closestCharacter.HumanoidRootPart.CFrame
end
assistant