Attempt to index nil with 'FindFirstChild'

Error code line 24

local BadgeService = game:GetService("BadgeService")
local Players = game:GetService("Players")

local badgeID = script.Parent.BadgeID.Value

local function OnTouch(part, player)
	local success, result = pcall(function()
		return BadgeService:GetBadgeInfoAsync(badgeID) 
	end)
	print(success, result)
	if success then
		print("Badge:", result.Name)
		print("Enabled:", result.IsEnabled)
		print("Description:", result.Description)
		print("Icon:", "rbxassetid://" .. result.IconImageId)	
	else
		warn("Error while fetching badge info:", result)
	end
	local success, badgeInfo = pcall(function()
		return BadgeService:GetBadgeInfoAsync(badgeID)
	end)
	if success then
		if badgeInfo.IsEnabled then
			if part.Parent:FindFirstChild("Humanoid") ~= nil then
				player = Players:GetPlayerFromCharacter(part.Parent)
				if player ~= nil then
					local awarded, errorMessage = pcall(function()
						BadgeService:AwardBadge(player.userId, badgeID)
					end)
					if not awarded then
						warn("Error while awarding badge:", errorMessage)
					end
				end
			end
		else
			warn("Error while fetching badge info!")
		end
	end
end
Players.PlayerAdded:Connect(OnTouch)
script.Parent.Touched:connect(OnTouch)

on line 22, put this instead

if success and part.Parent ~= nil then

Should I delete 24 lines of code?

The most common problem with this error is that the parent doesn’t exist! Try printing (part.Name, part.Parent.Name) because most commonly it’s not gonna exist.

Your problem is merely just the issue of your playeradded event. See you just forgot that playeradded functions don’t hold a part argument, instead it’s a player argument. Now that may be the problem, however part should be player since it would be the very first argument in your function. But I could be wrong about that.

Tl;dr PlayerAdded doesn’t hold a ‘Part’ Argument, just a Player Argument.