How to make an npc look like a random player

Oh my bad, have to add a wait when child added otherwise will error

script.Parent.ChildAdded:Connect(function(child)
	if child:IsA("Accessory") then
		task.wait()
		if child.AccessoryType ~= Enum.AccessoryType.Hat and child.AccessoryType ~= Enum.AccessoryType.Hair then 
			child:Destroy() 
		end
	end
end)

local function findnewDesc()
	local humanoid = script.Parent:WaitForChild('Humanoid')

	local UserId = math.random(1,1900000000)


	local HumanoidDescription 

	local suc ,erro = pcall(function()

		HumanoidDescription =   game.Players:GetHumanoidDescriptionFromUserId(UserId)
	end)
	if suc then
		humanoid:ApplyDescription(HumanoidDescription)
	else 
		wait()
		print(erro)
		findnewDesc()
	end	
end
findnewDesc()

This will work

2 Likes